diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8c7f823a07..e377cd02ab 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1567,7 +1567,7 @@ /types/hapi/v12/ @jasonswearingen /types/hapi/v15/ @jasonswearingen /types/hapi/v16/ @jasonswearingen @AJamesPhillips -/types/hapi/ @BorntraegerMarc @rafaelsouzaf @jhsimms @SimonSchick +/types/hapi/ @rafaelsouzaf @jhsimms @SimonSchick /types/hapi-auth-basic/ @AJamesPhillips @saboya /types/hapi-auth-jwt2/v7/ @warrenseymour /types/hapi-auth-jwt2/ @warrenseymour @SimonSchick diff --git a/types/bluebird-global/bluebird-global-tests.ts b/types/bluebird-global/bluebird-global-tests.ts index 0464b188cd..b6bbb915e2 100644 --- a/types/bluebird-global/bluebird-global-tests.ts +++ b/types/bluebird-global/bluebird-global-tests.ts @@ -40,3 +40,7 @@ function testPromiseRejection() { return value.toUpperCase(); }); } + +function testGithubTicket28081Regression() { + Promise.resolve([3]).map((n: number) => true); +} diff --git a/types/bluebird-global/index.d.ts b/types/bluebird-global/index.d.ts index 0d8ac4eeb3..7f38f981f1 100644 --- a/types/bluebird-global/index.d.ts +++ b/types/bluebird-global/index.d.ts @@ -67,52 +67,52 @@ declare global { * Patch all instance method */ interface Promise { - all: typeof Bluebird.prototype.all; - any: typeof Bluebird.prototype.any; - asCallback: typeof Bluebird.prototype.asCallback; - bind: typeof Bluebird.prototype.bind; - call: typeof Bluebird.prototype.call; - cancel: typeof Bluebird.prototype.cancel; - // catch: typeof Bluebird.prototype.catch; - caught: typeof Bluebird.prototype.caught; - delay: typeof Bluebird.prototype.delay; - disposer: typeof Bluebird.prototype.disposer; - done: typeof Bluebird.prototype.done; - each: typeof Bluebird.prototype.each; - error: typeof Bluebird.prototype.error; - filter: typeof Bluebird.prototype.filter; - // finally: typeof Bluebird.prototype.finally; - get: typeof Bluebird.prototype.get; - isCancelled: typeof Bluebird.prototype.isCancelled; - isFulfilled: typeof Bluebird.prototype.isFulfilled; - isPending: typeof Bluebird.prototype.isPending; - isRejected: typeof Bluebird.prototype.isRejected; - isResolved: typeof Bluebird.prototype.isResolved; - lastly: typeof Bluebird.prototype.lastly; - map: typeof Bluebird.prototype.map; - mapSeries: typeof Bluebird.prototype.mapSeries; - nodeify: typeof Bluebird.prototype.nodeify; - props: typeof Bluebird.prototype.props; - race: typeof Bluebird.prototype.race; - reason: typeof Bluebird.prototype.reason; - reduce: typeof Bluebird.prototype.reduce; - reflect: typeof Bluebird.prototype.reflect; - return: typeof Bluebird.prototype.return; - some: typeof Bluebird.prototype.some; - spread: typeof Bluebird.prototype.spread; - suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections; - tap: typeof Bluebird.prototype.tap; - tapCatch: typeof Bluebird.prototype.tapCatch; - // then: typeof Bluebird.prototype.then; - thenReturn: typeof Bluebird.prototype.thenReturn; - thenThrow: typeof Bluebird.prototype.thenThrow; - catchReturn: typeof Bluebird.prototype.catchReturn; - catchThrow: typeof Bluebird.prototype.catchThrow; - throw: typeof Bluebird.prototype.throw; - timeout: typeof Bluebird.prototype.timeout; - toJSON: typeof Bluebird.prototype.toJSON; - toString: typeof Bluebird.prototype.toString; - value: typeof Bluebird.prototype.value; + all: Bluebird["all"]; + any: Bluebird["any"]; + asCallback: Bluebird["asCallback"]; + bind: Bluebird["bind"]; + call: Bluebird["call"]; + cancel: Bluebird["cancel"]; + // catch: Bluebird["catch"]; + caught: Bluebird["caught"]; + delay: Bluebird["delay"]; + disposer: Bluebird["disposer"]; + done: Bluebird["done"]; + each: Bluebird["each"]; + error: Bluebird["error"]; + filter: Bluebird["filter"]; + // finally: Bluebird["finally"]; + get: Bluebird["get"]; + isCancelled: Bluebird["isCancelled"]; + isFulfilled: Bluebird["isFulfilled"]; + isPending: Bluebird["isPending"]; + isRejected: Bluebird["isRejected"]; + isResolved: Bluebird["isResolved"]; + lastly: Bluebird["lastly"]; + map: Bluebird["map"]; + mapSeries: Bluebird["mapSeries"]; + nodeify: Bluebird["nodeify"]; + props: Bluebird["props"]; + race: Bluebird["race"]; + reason: Bluebird["reason"]; + reduce: Bluebird["reduce"]; + reflect: Bluebird["reflect"]; + return: Bluebird["return"]; + some: Bluebird["some"]; + spread: Bluebird["spread"]; + suppressUnhandledRejections: Bluebird["suppressUnhandledRejections"]; + tap: Bluebird["tap"]; + tapCatch: Bluebird["tapCatch"]; + // then: Bluebird["then"]; + thenReturn: Bluebird["thenReturn"]; + thenThrow: Bluebird["thenThrow"]; + catchReturn: Bluebird["catchReturn"]; + catchThrow: Bluebird["catchThrow"]; + throw: Bluebird["throw"]; + timeout: Bluebird["timeout"]; + toJSON: Bluebird["toJSON"]; + toString: Bluebird["toString"]; + value: Bluebird["value"]; /* * Copy&paste ::then and ::catch from lib.es2015.promise.d.ts, because Bluebird's typings are not diff --git a/types/c3/c3-tests.ts b/types/c3/c3-tests.ts index f2e630cd09..6d7ea67287 100644 --- a/types/c3/c3-tests.ts +++ b/types/c3/c3-tests.ts @@ -452,6 +452,7 @@ function gauge_examples() { max: 100, units: " %", width: 10, + fullCircle: true, } }); } diff --git a/types/c3/index.d.ts b/types/c3/index.d.ts index 6c466458e3..0d94347ca3 100644 --- a/types/c3/index.d.ts +++ b/types/c3/index.d.ts @@ -276,6 +276,12 @@ export interface ChartConfiguration { * Set width of gauge chart. */ width?: number; + /** + * Whether this should be displayed + * as a full circle instead of a + * half circle. + */ + fullCircle?: boolean; }; spline?: { diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 6dbf118947..49f079e159 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4959,6 +4959,7 @@ declare namespace chrome.runtime { export interface ConnectInfo { name?: string; + includeTlsChannelId?: boolean; } export interface InstalledDetails { diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 6dbfef6e60..5ece4f497e 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -15,7 +15,7 @@ declare function CodeMirror(callback: (host: HTMLElement) => void , options?: Co declare namespace CodeMirror { export var Doc : CodeMirror.DocConstructor; export var Pos: CodeMirror.PositionConstructor; - export var Pass: any; + export var Pass: {toString(): "CodeMirror.PASS"}; function countColumn(line: string, index: number | null, tabSize: number): number; function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea; @@ -129,6 +129,10 @@ declare namespace CodeMirror { state: any; } + interface KeyMap { + [keyName: string]: false | string | ((instance: Editor) => void | typeof Pass); + } + interface Editor { /** Tells you whether the editor currently has focus. */ @@ -159,11 +163,11 @@ declare namespace CodeMirror { Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them, the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed, in which case they end up below other keymaps added with this method. */ - addKeyMap(map: any, bottom?: boolean): void; + addKeyMap(map: string | KeyMap, bottom?: boolean): void; /** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string, which will be compared against the name property of the active keymaps. */ - removeKeyMap(map: any): void; + removeKeyMap(map: string | KeyMap): void; /** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting. For example, the search add - on uses it to highlight the term that's currently being searched. @@ -716,8 +720,9 @@ declare namespace CodeMirror { } interface EditorChangeCancellable extends CodeMirror.EditorChange { - /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */ - update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; + /** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. + If the change came from undo/redo, `update` is undefined and the change cannot be modified. */ + update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void; cancel(): void; } @@ -780,7 +785,7 @@ declare namespace CodeMirror { keyMap?: string; /** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */ - extraKeys?: any; + extraKeys?: string | KeyMap; /** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */ lineWrapping?: boolean; diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index 39c601f159..bd2aefac88 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -4,7 +4,18 @@ var myCodeMirror: CodeMirror.Editor = CodeMirror(document.body); var myCodeMirror2: CodeMirror.Editor = CodeMirror(document.body, { value: "function myScript(){return 100;}\n", - mode: "javascript" + mode: "javascript", + extraKeys: { + Enter: (cm) => { console.log("save"); }, + Esc: (cm) => { return CodeMirror.Pass; } + } +}); + +// $ExpectError +var myCodeMirror2_1: CodeMirror.Editor = CodeMirror(document.body, { + extraKeys: { + "Shift-Enter": (cm) => { return 42; } // not a valid return value + } }); var range = myCodeMirror2.findWordAt(CodeMirror.Pos(0, 2)); @@ -13,9 +24,9 @@ var head = range.head; var from = range.from(); var to = range.to(); -var myTextArea: HTMLTextAreaElement; +var myTextArea: HTMLTextAreaElement = undefined!; var myCodeMirror3: CodeMirror.Editor = CodeMirror(function (elt) { - myTextArea.parentNode.replaceChild(elt, myTextArea); + myTextArea.parentNode!.replaceChild(elt, myTextArea); }, { value: myTextArea.value }); var myCodeMirror4: CodeMirror.Editor = CodeMirror.fromTextArea(myTextArea); @@ -67,6 +78,15 @@ myCodeMirror.on( (instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => { } ); +myCodeMirror.on( + "beforeChange", + (instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => { + // $ExpectError + change.update(); + if (change.update != null) change.update(); + } +); + CodeMirror.registerHelper("lint", "javascript", {}); myCodeMirror.isReadOnly(); diff --git a/types/codemirror/tsconfig.json b/types/codemirror/tsconfig.json index 2ff349d98e..a2c6a52430 100644 --- a/types/codemirror/tsconfig.json +++ b/types/codemirror/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/copy-webpack-plugin/index.d.ts b/types/copy-webpack-plugin/index.d.ts index eedf42f450..59c1b8d0cb 100644 --- a/types/copy-webpack-plugin/index.d.ts +++ b/types/copy-webpack-plugin/index.d.ts @@ -61,7 +61,7 @@ interface CopyWebpackPluginConfiguration { } interface CopyWebpackPlugin { - new (patterns?: CopyPattern[], options?: CopyWebpackPluginConfiguration): Plugin + new (patterns?: (string | CopyPattern)[], options?: CopyWebpackPluginConfiguration): Plugin } declare const copyWebpackPlugin: CopyWebpackPlugin diff --git a/types/styled-system/package.json b/types/dd-trace/package.json similarity index 58% rename from types/styled-system/package.json rename to types/dd-trace/package.json index da1a3181d0..90deb3c97b 100644 --- a/types/styled-system/package.json +++ b/types/dd-trace/package.json @@ -1,6 +1,6 @@ { "private": true, "dependencies": { - "styled-components": "^3.3.2" + "opentracing": ">=0.14.1" } } diff --git a/types/dd-trace/src/opentracing/reference.d.ts b/types/dd-trace/src/opentracing/reference.d.ts deleted file mode 100644 index 57def49166..0000000000 --- a/types/dd-trace/src/opentracing/reference.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Span = require('./span'); -import SpanContext = require('./span_context'); - -declare class Reference { - /** - * @return The Reference type (e.g., REFERENCE_CHILD_OF or - * REFERENCE_FOLLOWS_FROM). - */ - type(): string; - - /** - * @return The SpanContext being referred to (e.g., the - * parent in a REFERENCE_CHILD_OF Reference). - */ - referencedContext(): SpanContext; - - /** - * Initialize a new Reference instance. - * - * @param type - the Reference type constant (e.g., - * REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM). - * @param referencedContext - the SpanContext being referred - * to. As a convenience, a Span instance may be passed in instead - * (in which case its .context() is used here). - */ - constructor(type: string, referencedContext: SpanContext | Span); -} - -export = Reference; \ No newline at end of file diff --git a/types/dd-trace/src/opentracing/span.d.ts b/types/dd-trace/src/opentracing/span.d.ts index e61a611efd..cf9286210b 100644 --- a/types/dd-trace/src/opentracing/span.d.ts +++ b/types/dd-trace/src/opentracing/span.d.ts @@ -1,7 +1,8 @@ import Tracer = require('./tracer'); import SpanContext = require('./span_context'); +import { Span } from 'opentracing'; -declare class Span { +declare class DatadogSpan extends Span { /** * Returns the SpanContext object associated with this Span. */ @@ -117,4 +118,4 @@ declare class Span { finish(finishTime?: number): void; } -export = Span; +export = DatadogSpan; diff --git a/types/dd-trace/src/opentracing/span_context.d.ts b/types/dd-trace/src/opentracing/span_context.d.ts index 4e3b532649..cf9565d5a5 100644 --- a/types/dd-trace/src/opentracing/span_context.d.ts +++ b/types/dd-trace/src/opentracing/span_context.d.ts @@ -1,3 +1,5 @@ +import { SpanContext } from 'opentracing'; + /** * SpanContext represents Span state that must propagate to descendant Spans * and across process boundaries. @@ -8,7 +10,7 @@ * identify or otherwise contextualize the associated Span instance (e.g., a * tuple). */ -declare class SpanContext { +declare class DatadogSpanContext extends SpanContext { /** * Use to create references to parent spans. */ @@ -35,4 +37,4 @@ interface SpanContextLike { spanId: number; } -export = SpanContext; +export = DatadogSpanContext; diff --git a/types/dd-trace/src/opentracing/span_options.d.ts b/types/dd-trace/src/opentracing/span_options.d.ts deleted file mode 100644 index 054d9024d1..0000000000 --- a/types/dd-trace/src/opentracing/span_options.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import Span = require('./span'); -import Reference = require('./reference'); -import SpanContext = require('./span_context'); - -interface SpanOptions { - /** - * a parent SpanContext (or Span, for convenience) that the newly-started - * span will be the child of (per REFERENCE_CHILD_OF). If specified, - * `references` must be unspecified. - */ - childOf?: Span | SpanContext; - - /** - * an array of Reference instances, each pointing to a causal parent - * SpanContext. If specified, `fields.childOf` must be unspecified. - */ - references?: Reference[]; - - /** - * set of key-value pairs which will be set as tags on the newly created - * Span. Ownership of the object is passed to the created span for - * efficiency reasons (the caller should not modify this object after - * calling startSpan). - */ - tags?: { - [key: string]: any; - }; - - /** - * a manually specified start time for the created Span object. The time - * should be specified in milliseconds as Unix timestamp. Decimal value are - * supported to represent time values with sub-millisecond accuracy. - */ - startTime?: number; -} - -export = SpanOptions; diff --git a/types/dd-trace/src/opentracing/tracer.d.ts b/types/dd-trace/src/opentracing/tracer.d.ts index a40559dbcd..252a0d558c 100644 --- a/types/dd-trace/src/opentracing/tracer.d.ts +++ b/types/dd-trace/src/opentracing/tracer.d.ts @@ -1,91 +1,11 @@ -import SpanOptions = require('./span_options'); -import Span = require('./span'); -import SpanContext = require('./span_context'); +import { Tracer } from 'opentracing'; /** * Tracer is the entry-point between the instrumentation API and the tracing * implementation. */ -declare class Tracer { - /** - * Starts and returns a new Span representing a logical unit of work. - * - * For example: - * - * // Start a new (parentless) root Span: - * var parent = Tracer.startSpan('DoWork'); - * - * // Start a new (child) Span: - * var child = Tracer.startSpan('load-from-db', { - * childOf: parent.context(), - * }); - * - * // Start a new async (FollowsFrom) Span: - * var child = Tracer.startSpan('async-cache-write', { - * references: [ - * opentracing.followsFrom(parent.context()) - * ], - * }); - * - * @param name - the name of the operation (REQUIRED). - * @param options - options for the newly created span. - * @return A new Span object. - */ - startSpan(name: string, options?: SpanOptions): Span; +declare class DatadogTracer extends Tracer { - /** - * Injects the given SpanContext instance for cross-process propagation - * within `carrier`. The expected type of `carrier` depends on the value of - * `format. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * var clientSpan = ...; - * ... - * // Inject clientSpan into a text carrier. - * var headersCarrier = {}; - * Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * // Incorporate the textCarrier into the outbound HTTP request header - * // map. - * Object.assign(outboundHTTPReq.headers, headersCarrier); - * // ... send the httpReq - * - * @param spanContext - the SpanContext to inject into the - * carrier object. As a convenience, a Span instance may be passed - * in instead (in which case its .context() is used for the - * inject()). - * @param format - the format of the carrier. - * @param carrier - see the documentation for the chosen `format` - * for a description of the carrier object. - */ - inject(spanContext: SpanContext | Span, format: string, carrier: any): void; - - /** - * Returns a SpanContext instance extracted from `carrier` in the given - * `format`. - * - * OpenTracing defines a common set of `format` values (see - * FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has - * an expected carrier type. - * - * Consider this pseudocode example: - * - * // Use the inbound HTTP request's headers as a text map carrier. - * var headersCarrier = inboundHTTPReq.headers; - * var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier); - * var serverSpan = Tracer.startSpan('...', { childOf : wireCtx }); - * - * @param format - the format of the carrier. - * @param carrier - the type of the carrier object is determined by - * the format. - * @return The extracted SpanContext, or null if no such SpanContext could - * be found in `carrier` - */ - extract(format: string, carrier: any): SpanContext | null; } -export = Tracer; +export = DatadogTracer; diff --git a/types/echarts/index.d.ts b/types/echarts/index.d.ts index 15892864e5..bfbd7af809 100644 --- a/types/echarts/index.d.ts +++ b/types/echarts/index.d.ts @@ -1,122 +1,414 @@ -// Type definitions for echarts +// Type definitions for echarts 4.1.0 // Project: http://echarts.baidu.com/ // Definitions by: Xie Jingyang // AntiMoron // Liveangela +// Ovilia // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 declare namespace echarts { - function init(dom: HTMLDivElement | HTMLCanvasElement, theme?: object | string, opts?: { - devicePixelRatio?: number - renderer?: string - width?: number | string - height?: number | string - }): ECharts; + /** + * Creates an ECharts instance, and returns an echartsInstance. You shall + * not initialize multiple ECharts instances on a single container. + * + * @param {HTMLDivElement | HTMLCanvasElement} dom Instance container, + * usually is a `div` element with height and width defined. + * @param {object | string} [theme] Theme to be applied. + * This can be a configuring object of a theme, or a theme name + * registered through [echarts.registerTheme](https://echarts.apache.org/api.html#echarts.registerTheme). + * @param {object} [opts] Chart configurations. + * @param {number} [opts.devicePixelRatio] Ratio of one physical pixel to + * the size of one device independent pixels. Browser's + * `window.devicePixelRatio` is used by default. + * @param {string} [opts.renderer] Supports `'canvas'` or `'svg'`. + * See [Render by Canvas or SVG](https://echarts.apache.org/tutorial.html#Render%20by%20Canvas%20or%20SVG). + * @param {number} [opts.width] Specify width explicitly, in pixel. + * If setting to `null`/`undefined`/`'auto'`, width of `dom` + * (instance container) will be used. + * @param {number} [opts.height] Specify height explicitly, in pixel. + * If setting to `null`/`undefined`/`'auto'`, height of `dom` + * (instance container) will be used. + */ + function init( + dom: HTMLDivElement | HTMLCanvasElement, + theme?: object | string, + opts?: { + devicePixelRatio?: number + renderer?: string + width?: number | string + height?: number | string + } + ): ECharts - const graphic: Graphic; + /** + * Connects interaction of multiple chart series. For example: + * + ```js + // set group id of each instance respectively. + chart1.group = 'group1'; + chart2.group = 'group1'; + echarts.connect('group1'); + // or incoming instance array that need to be linked. + echarts.connect([chart1, chart2]); + ``` + * + * @param group Group id in string, or array of chart instance. + */ + function connect(group: string | ECharts[]): void - interface Graphic { - clipPointsByRect(points: number[][], rect: ERectangle): number[][]; - clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle; - LinearGradient: { new(x: number, y: number, x2: number, y2: number, colorStops: object[], globalCoord?: boolean): LinearGradient } - } + /** + * Disconnects interaction of multiple chart series. To have one single + * instance to be removed, you can set `group` of chart instance to be null. + * + * @param {string} group Group id in string. + */ + function disConnect(group: string): void - function connect(group: string | string[]): void; + /** + * Destroys chart instance, after which the instance cannot be used any + * more. + * + * @param target Chart instance or container. + */ + function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement) + : void - function disConnect(group: string): void; + /** + * Returns chart instance of dom container. + * + * @param target Chart container. + */ + function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement) + : ECharts - function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement): void; + /** + * Registers available maps. This can only be used after including + * [geo](https://echarts.apache.org/option.html#geo) + * component or chart series of + * [map](https://echarts.apache.org/option.html#series-map). + * + * @param {string} mapName Map name, referring to `map` value set in + * [geo](https://echarts.apache.org/option.html#geo) + * component or + * [map](https://echarts.apache.org/option.html#series-map). + * @param {object} geoJson Data in GeoJson format. See + * [http://geojson.org/](http://geojson.org/) for more format information. + * @param {object} [specialAreas] Zoomed part of a specific area in the map + * for better visual effect. + * See [USA Population Estimates example](https://ecomfe.github.io/echarts-examples/public/editor.html?c=map-usa). + */ + function registerMap( + mapName: string, + geoJson: object, + specialAreas?: object + ): void - function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement): ECharts; - - function registerMap(mapName: string, geoJson: object, specialAreas?: object): void; - - function registerTheme(themeName: string, theme: object): void; + /** + * Registers a theme, should be specified when + * [initialize the chart instance](https://echarts.apache.org/api.html#echarts.init). + * + * @param {string} themeName Theme name. + * @param {object} theme Theme configurations. + */ + function registerTheme(themeName: string, theme: object): void interface MapObj { - /** geoJson data for map */ + /** + * geoJson data for map + */ geoJson: object, - /** special areas fro map */ + /** + * special areas fro map + */ specialAreas: object } - function getMap(mapName: string): MapObj; + /** + * Get a registed map. + * + * @param {string} mapName Map name. + * @return {MapObj} Map data. + */ + function getMap(mapName: string): MapObj - interface LinearGradient { - colorStops: object[]; - global: boolean; - type: string; - x: number - x2: number - y: number - y2: number + /** + * Util methods about graphics. + */ + const graphic: Graphic; + + interface Graphic { + /** + * Clip the given points by the given rectangular. + * + * @param {number[][]} points The points to be clipped, + * like [[23, 44], [12, 15], ...]. + * @param {ERectangle} rect The rectangular that is used to clip points. + */ + clipPointsByRect(points: number[][], rect: ERectangle): number[][]; + + /** + * Clip the first input rectangular by the second input rectangular. + * + * @param {ERectangle} targetRect The rectangular to be clipped. + * @param {ERectangle} rect The rectangular that is used to clip + * targetRect. + */ + clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle; } interface ECharts { + /** + * Group name to be used in chart connection + */ group: string - setOption(option: EChartOption, notMerge?: boolean, notRefreshImmediately?: boolean): void + /** + * Configuration item, data, universal interface, all parameters and + * data can all be modified through `setOption`. ECharts will merge + * new parameters and data, and then refresh chart. + * + * @param {EChartOption} option Configuration item and data. Please + * refer to [configuration item manual](https://echarts.apache.org/option.html) + * for more information. + * @param {boolean} [notMerge=false] Whether not to merge with previous + * `option` + * @param {boolean} [lazyUpdate=false] Whether not to update chart + * immediately + */ + setOption( + option: EChartOption, + notMerge?: boolean, + lazyUpdate?: boolean + ) : void + /** + * Configuration item, data, universal interface, all parameters and + * data can all be modified through `setOption`. ECharts will merge + * new parameters and data, and then refresh chart. + * + * @param {EChartOption} option Configuration item and data. Please + * refer to [configuration item manual](https://echarts.apache.org/option.html) + * for more information. + * @param {EChartsOptionConfig} [opts] Options about how to setOption + */ + setOption(option: EChartOption, opts?: EChartsOptionConfig): void + + /** + * Gets width of ECharts instance container. + * + * @return {number} Width. + */ getWidth(): number + /** + * Gets height of ECharts instance container. + * + * @return {number} Height. + */ getHeight(): number + /** + * Gets DOM element of ECharts instance container. + * + * @return {HTMLCanvasElement|HTMLDivElement} DOM container. + */ getDom(): HTMLCanvasElement | HTMLDivElement - getOption(): object + /** + * Gets `option` object maintained in current instance, which contains + * configuration item and data merged from previous `setOption` + * operations by users, along with user interaction states. + * For example, switching of legend, zooming area of data zoom, + * and so on. Therefore, a new instance that is exactly the same + * can be recovered from this option. + */ + getOption(): EChartOption - resize(): void + /** + * Resizes chart, which should be called manually when container size + * changes. When `opts` is not provided, DOM size is used. + * + * @param {EChartsResizeOption} opts Specify parameters explicitly. + */ + resize(opts?: EChartsResizeOption): void + /** + * Triggers chart action, like chart switch `legendToggleSelect`, + * zoom data area `dataZoom`, show tooltip `showTip` and so on. + * See [action](https://echarts.apache.org/api.html#action) and + * [events](https://echarts.apache.org/api.html#events) + * for more information. + * + * @param payload Trigger multiple actions through `batch` attribute. + */ dispatchAction(payload: object): void + /** + * Binds event-handling function. + * There are two kinds of events in ECharts, one of which is mouse + * events, which will be triggered when the mouse clicks certain + * element in the chart, the other kind will be triggered after + * `dispatchAction` is called. Every action has a corresponding + * event. + * If event is triggered externally by `dispatchAction`, and there + * is batch attribute in action to trigger batch action, then the + * corresponding response event parameters be in batch. + * + * @param {string} eventName Event names are all in lower-cases, + * for example, `'click'`, `'mousemove'`, `'legendselected'` + * @param {Function} handler Event-handling function, whose format + * is as following: + ```js + (event: object) + ``` + * @param {object} [context] context of callback function, what + * `this` refers to. + */ on(eventName: string, handler: Function, context?: object): void + /** + * Unbind event-handler function. + * + * @param {string} eventName Event names are all in lower-cases, + * for example, `'click'`, `'mousemove'`, `'legendselected'` + * @param {Function} [handler] The function to be unbound could be + * passed. Otherwise, all event functions of this type will be + * unbound. + */ off(eventName: string, handler?: Function): void - showLoading(type?: string, opts?: object): void + /** + * Convert a point from logical coordinate (e.g., in geo, cartesian, + * graph, ...) to pixel coordinate. + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be converted. + */ + convertToPixel(finder: EChartsConvertFinder, value: string | any[]) + : string | any[] + /** + * Convert a point from pixel coordinate to logical coordinate + * (e.g., in geo, cartesian, graph, ...). + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be converted. + */ + convertFromPixel(finder: EChartsConvertFinder, value: any[] | string) + : any[] | string + + /** + * Determine whether the given point is in the given coordinate systems or series. + * + * @param {EChartsConvertFinder} finder Indicate in which coordinate + * system conversion is performed. + * Generally, index or id or name can be used to specify + * coordinate system. + * @param {string | any[]} value The value to be judged, in pixel + * coordinate system. + */ + containPixel(finder: EChartsConvertFinder, value: any[]): boolean + + /** + * Shows loading animation. You can call this interface manually before + * data is loaded, and call `hideLoading` to hide loading animation + * after data is loaded. + * + * @param {string} [type='default'] + * @param {EChartsLoadingOption} [opts] + */ + showLoading(type?: string, opts?: EChartsLoadingOption): void + + /** + * Hides animation loading effect. + */ hideLoading(): void + /** + * Exports chart image; returns a base64 URL; can be set to `src` of + * `Image`. + * + * @param opts Options. + */ getDataURL(opts: { - /** 导出的格式,可选 png, jpeg */ + // Exporting format, can be either png, or jpeg type?: string, - /** 导出的图片分辨率比例,默认为 1。*/ + // Resolution ratio of exporting image, 1 by default. pixelRatio?: number, - /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ - backgroundColor?: string + // Background color of exporting image, use backgroundColor in + // option by default. + backgroundColor?: string, + // Excluded components list. e.g. ['toolbox'] + excludeComponents?: string[] }): string + /** + * Exports connected chart image; returns a base64 url; can be set to + * `src` of `Image`. Position of charts in exported image are + * related to that of the container. + * + * @param opts Options. + */ getConnectedDataURL(opts: { - /** 导出的格式,可选 png, jpeg */ + // Exporting format, can be either png, or jpeg type: string, - /** 导出的图片分辨率比例,默认为 1。 */ + // Resolution ratio of exporting image, 1 by default. pixelRatio: number, - /** 导出的图片背景色,默认使用 option 里的 backgroundColor */ - backgroundColor: string + // Background color of exporting image, use backgroundColor in + // option by default. + backgroundColor: string, + // Excluded components list. e.g. ['toolbox'] + excludeComponents?: string[] }): string + /** + * The method is used in rendering millions of data + * (e.g. rendering geo data). In these scenario, the entire size of + * data is probably up to 10 or 100 MB, even using binary format. + * So chunked load data and rendering is required. When using + * `appendData`, the graphic elements that have been rendered will + * not be cleared, but keep rendering new graphic elements. + * + * @param opts Data options. + */ + appendData(opts: { + // Specify which series the data will be appended to. + seriesIndex?: string, + // The data to be appended. + data?: any[]|TypedArray, + }): void + + /** + * Clears current instance; removes all components and charts in + * current instance. + */ clear(): void + /** + * Returns whether current instance has been disposed. + * + * @return {boolean} Whether has been disposed. + */ isDisposed(): boolean + /** + * Disposes instance. Once disposed, the instance can not be used again. + */ dispose(): void - - /** 转换逻辑点到像素 */ - convertToPixel(finder: ConvertFinder | string, value: string | any[]): string | any[] - - convertFromPixel(finder: ConvertFinder | string, value: any[] | string): any[] | string - - containPixel(finder: ConvertFinder | string, - /** 要被判断的点,为像素坐标值,以 echarts 实例的 dom 节点的左上角为坐标 [0, 0] 点。*/ - value: any[]): boolean - - getModel(): { - getComponent(finder: string): any; - } } - interface ConvertFinder { + type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array + | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array + | Float64Array; + + interface EChartsConvertFinder { seriesIndex?: number, seriesId?: string, seriesName?: string, @@ -193,6 +485,29 @@ declare namespace echarts { zAxis3D?: object } + interface EChartsOptionConfig { + notMerge?: boolean, + lazyUpdate?: boolean, + silent?: boolean + } + + interface EChartsResizeOption { + /** + * Chart width. + */ + width?: number | string, + + /** + * Chart height. + */ + heiight?: number | string, + + /** + * Specify whether or not to prevent triggering events. + */ + silent?: boolean + } + interface EChartTitleOption { show?: boolean; text?: string; @@ -219,6 +534,38 @@ declare namespace echarts { shadowOffsetX?: number, shadowOffsetY?: number, } + + interface EChartsLoadingOption { + /** + * Loading text. + * @default 'loading' + */ + text?: string, + + /** + * Loading circle color. + * @default '#c23531' + */ + color?: string, + + /** + * Loading text color. + * @default '#000' + */ + textColor?: string, + + /** + * Mask background color. + * @default 'rgba(255, 255, 255, 0.8)' + */ + maskColor?: string, + + /** + * Zlevel of loading. If not 0, it creates a new canvas for loading. + * @default 0 + */ + zlevel?: 0 + } } declare module 'echarts' { diff --git a/types/emoji-mart/dist-es/components/category.d.ts b/types/emoji-mart/dist-es/components/category.d.ts index 8cd4ceefbb..efa52e9988 100644 --- a/types/emoji-mart/dist-es/components/category.d.ts +++ b/types/emoji-mart/dist-es/components/category.d.ts @@ -1,12 +1,11 @@ import React = require('react'); -import { EmojiData } from '..'; - -import { Emoji, EmojiProps, I18n } from '.'; +import { Emoji, EmojiData, EmojiProps, I18n, CategoryName } from '..'; export interface Props { emojis?: Array; hasStickyPosition?: boolean; + id: CategoryName; name: string; native: boolean; perLine: number; diff --git a/types/emoji-mart/dist-es/components/emoji.d.ts b/types/emoji-mart/dist-es/components/emoji.d.ts deleted file mode 100644 index 030ff7ce12..0000000000 --- a/types/emoji-mart/dist-es/components/emoji.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import React = require('react'); - -import { EmojiData, EmojiSkin } from '..'; - -export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string; -export type EmojiSet = 'apple'|'google'|'twitter'|'emojione'|'messenger'|'facebook'; -export type EmojiSheetSize = 16|20|32|64; - -export interface Props { - onOver?(emoji: EmojiData, e: React.MouseEvent): void; - onLeave?(emoji: EmojiData, e: React.MouseEvent): void; - onClick?(emoji: EmojiData, e: React.MouseEvent): void; - /** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */ - backgroundImageFn?: BackgroundImageFn; - native?: boolean; - forceSize?: boolean; - tooltip?: boolean; - /** defaults to 1 */ - skin?: EmojiSkin; - /** defaults to 64 */ - sheetSize?: EmojiSheetSize; - /** defaults to 'apple' */ - set?: EmojiSet; - size: number; - emoji: string|EmojiData; -} - -// tslint:disable-next-line strict-export-declare-modifiers -declare const Emoji: React.SFC; - -export { Emoji as default }; diff --git a/types/emoji-mart/dist-es/components/emoji/emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts new file mode 100644 index 0000000000..d86d2b686f --- /dev/null +++ b/types/emoji-mart/dist-es/components/emoji/emoji.d.ts @@ -0,0 +1,8 @@ +import React = require('react'); + +import { EmojiProps } from '../..'; + +// tslint:disable-next-line strict-export-declare-modifiers +declare const Emoji: React.StatelessComponent; + +export { Emoji as default }; diff --git a/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts new file mode 100644 index 0000000000..77888f5a94 --- /dev/null +++ b/types/emoji-mart/dist-es/components/emoji/nimble-emoji.d.ts @@ -0,0 +1,12 @@ +import React = require('react'); + +import { EmojiProps, Data } from '../..'; + +export interface NimbleEmojiProps extends EmojiProps { + data: Data; +} + +// tslint:disable-next-line strict-export-declare-modifiers +declare const NimbleEmoji: React.SFC; + +export { NimbleEmoji as default }; diff --git a/types/emoji-mart/dist-es/components/index.d.ts b/types/emoji-mart/dist-es/components/index.d.ts index 6fc29ecd54..3f05ca5c82 100644 --- a/types/emoji-mart/dist-es/components/index.d.ts +++ b/types/emoji-mart/dist-es/components/index.d.ts @@ -1,4 +1,6 @@ // The other exports on the components folder are not public API export { default as Category, Props as CategoryProps } from './category'; -export { default as Emoji, Props as EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from './emoji'; -export { default as Picker, Props as PickerProps, I18n, PartialI18n, CustomEmoji } from './picker'; +export { default as Emoji } from './emoji/emoji'; +export { default as NimbleEmoji, NimbleEmojiProps } from './emoji/nimble-emoji'; +export { default as Picker } from './picker/picker'; +export { default as NimblePicker, NimblePickerProps } from './picker/nimble-picker'; diff --git a/types/emoji-mart/dist-es/components/picker.d.ts b/types/emoji-mart/dist-es/components/picker.d.ts deleted file mode 100644 index 9f9132df05..0000000000 --- a/types/emoji-mart/dist-es/components/picker.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -import React = require('react'); - -import { EmojiData, EmojiSkin } from '..'; - -import { Category, Emoji, EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from '.'; - -// tslint:disable-next-line interface-name -export interface I18n { - search: string; - categories: Record<'search'|'recent'|'people'|'nature'|'foods'|'activity'|'places'|'objects'|'symbols'|'flags'|'custom', string>; - notfound: string; -} - -export type PartialI18n = Partial & { categories: Partial}>; - -export interface CustomEmoji { - // id is overridden by short_names[0] - name: string; - /** Must contain at least one name. The first name is used as the unique id. */ - short_names: string[]; - emoticons?: string[]; - keywords?: string[]; - imageUrl: string; -} - -export interface Props { - /** NOTE: default is not preventable */ - onClick?(emoji: EmojiData, e: React.MouseEvent): void; - perLine?: number; - emojiSize?: number; - i18n?: PartialI18n; - style?: React.CSSProperties; - title?: string; - emoji?: string; - color?: string; - set?: EmojiSet; - skin?: EmojiSkin; - native?: boolean; - backgroundImageFn?: BackgroundImageFn; - sheetSize?: EmojiSheetSize; - emojisToShowFilter?(emoji: EmojiData): boolean; - showPreview?: boolean; - emojiTooltip?: boolean; - include?: string[]; - exclude?: string[]; - recent?: string[]; - autoFocus?: boolean; - /** NOTE: custom emoji are copied into a singleton object on every new mount */ - custom: CustomEmoji[]; -} - -export default class Picker extends React.PureComponent { - // everything inside it is supposed to be private -} diff --git a/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts new file mode 100644 index 0000000000..cc564b2a5e --- /dev/null +++ b/types/emoji-mart/dist-es/components/picker/nimble-picker.d.ts @@ -0,0 +1,11 @@ +import React = require('react'); + +import { Data, PickerProps } from '../..'; + +export interface NimblePickerProps extends PickerProps { + data: Data; +} + +export default class NimblePicker extends React.PureComponent { + // everything inside it is supposed to be private +} diff --git a/types/emoji-mart/dist-es/components/picker/picker.d.ts b/types/emoji-mart/dist-es/components/picker/picker.d.ts new file mode 100644 index 0000000000..01f8a41f8b --- /dev/null +++ b/types/emoji-mart/dist-es/components/picker/picker.d.ts @@ -0,0 +1,7 @@ +import React = require('react'); + +import { PickerProps } from '../..'; + +export default class Picker extends React.PureComponent { + // everything inside it is supposed to be private +} diff --git a/types/emoji-mart/dist-es/index.d.ts b/types/emoji-mart/dist-es/index.d.ts index e49d37fcf6..bb0c79be3e 100644 --- a/types/emoji-mart/dist-es/index.d.ts +++ b/types/emoji-mart/dist-es/index.d.ts @@ -1,15 +1,30 @@ -export { default as emojiIndex, EmojiData, EmojiSkin } from './utils/emoji-index'; export { default as store, StoreHandlers } from './utils/store'; export { default as frequently } from './utils/frequently'; +export { Data } from './utils/data'; + +export { + PickerProps, + EmojiProps, + I18n, + PartialI18n, + CategoryName +} from './utils/shared-props'; + +export { + emojiIndex, + nimbleEmojiIndex, + EmojiData, + CustomEmoji, + EmojiSkin +} from './utils/emoji-index'; export { Picker, - PickerProps, - I18n, - PartialI18n, - CustomEmoji, + NimblePicker, + NimblePickerProps, Emoji, - EmojiProps, + NimbleEmoji, + NimbleEmojiProps, Category, CategoryProps } from './components'; diff --git a/types/emoji-mart/dist-es/utils/data.d.ts b/types/emoji-mart/dist-es/utils/data.d.ts new file mode 100644 index 0000000000..ad1bc0d229 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/data.d.ts @@ -0,0 +1,73 @@ +export interface Data { + compressed: boolean; + categories: Category[]; + emojis: { [key: string]: Emoji }; + aliases: { [key: string]: string }; +} + +export interface Category { + id: string; + name: string; + emojis: string[]; +} + +export interface Emoji { + name?: string; + a?: string; + unified?: string; + b?: string; + non_qualified?: string; + c?: string; + has_img_apple?: boolean; + d?: boolean; + has_img_google?: boolean; + e?: boolean; + has_img_twitter?: boolean; + f?: boolean; + has_img_emojione?: boolean; + g?: boolean; + has_img_facebook?: boolean; + h?: boolean; + has_img_messenger?: boolean; + i?: boolean; + keywords?: string[]; + j?: string[]; + sheet?: number[]; + k?: number[]; + emoticons?: string[]; + l?: string[]; + text?: string; + m?: string; + short_names?: string[]; + n?: string[]; + added_in?: number; + o?: number; + sheet_x?: number; + sheet_y?: number; + skin_variations?: { [key: string]: SkinVariation }; + obsoleted_by?: string; + obsoletes?: string; +} + +export interface SkinVariation { + unified: string; + non_qualified: null | string; + image: string; + sheet_x: number; + sheet_y: number; + added_in: string; + has_img_apple: boolean; + has_img_google: boolean; + has_img_twitter: boolean; + has_img_emojione: boolean; + has_img_facebook: boolean; + has_img_messenger: boolean; + obsoleted_by?: string; + obsoletes?: string; +} + +export function buildSearch(emoji: Emoji): string; + +export function compress(emoji: Emoji): void; + +export function uncompress(data: Data): void; diff --git a/types/emoji-mart/dist-es/utils/emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index.d.ts deleted file mode 100644 index c6499e663c..0000000000 --- a/types/emoji-mart/dist-es/utils/emoji-index.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -export type EmojiSkin = 1|2|3|4|5|6; - -export interface EmojiData { - id: string; - name: string; - colons: string; - /** Reverse mapping to keyof emoticons */ - emoticons: string[]; - unified: string; - skin: EmojiSkin|null; - native: string; -} - -// tslint:disable-next-line strict-export-declare-modifiers -declare const _default: { - search(query: ''): null - search(query: string): EmojiData|null - - emojis: { [emoji: string]: EmojiData } - - /** Mapping of string to keyof emojis */ - emoticons: { [emoticon: string]: string } -}; - -export { _default as default }; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts new file mode 100644 index 0000000000..0d1d6b8881 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/emoji-index.d.ts @@ -0,0 +1,14 @@ +import { EmojiData } from './nimble-emoji-index'; + +// tslint:disable-next-line strict-export-declare-modifiers +declare const _default: { + search(query: ''): null; + search(query: string): EmojiData|null; + + emojis: { [emoji: string]: EmojiData }; + + /** Mapping of string to keyof emojis */ + emoticons: { [emoticon: string]: string }; +}; + +export { _default as default }; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts new file mode 100644 index 0000000000..576a5d0cb7 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/index.d.ts @@ -0,0 +1,2 @@ +export { default as emojiIndex } from './emoji-index'; +export { default as nimbleEmojiIndex, EmojiData, CustomEmoji, EmojiSkin } from './nimble-emoji-index'; diff --git a/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts b/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts new file mode 100644 index 0000000000..010c313d19 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/emoji-index/nimble-emoji-index.d.ts @@ -0,0 +1,40 @@ +import { Data } from "../data"; + +import { CategoryName } from '../shared-props'; + +export type EmojiSkin = 1 | 2 | 3 | 4 | 5 | 6; + +export interface BaseEmoji { + id: string; + name: string; + colons: string; + /** Reverse mapping to keyof emoticons */ + emoticons: string[]; + unified: string; + skin: EmojiSkin | null; + native: string; +} + +export interface CustomEmoji { + // id is overridden by short_names[0] + id?: string; + // colons is overridden by :id: + colons?: string; + name: string; + /** Must contain at least one name. The first name is used as the unique id. */ + short_names: string[]; + emoticons?: string[]; + keywords?: string[]; + imageUrl: string; +} + +export type EmojiData = BaseEmoji | CustomEmoji; + +export default class NimbleEmojiIndex { + constructor(data: Data); + search(query: ''): null; + search(query: string): EmojiData[]|null; + emojis: { [emoji: string]: EmojiData }; + /** Mapping of string to keyof emojis */ + emoticons: { [emoticon: string]: string }; +} diff --git a/types/emoji-mart/dist-es/utils/shared-props.d.ts b/types/emoji-mart/dist-es/utils/shared-props.d.ts new file mode 100644 index 0000000000..c091e24556 --- /dev/null +++ b/types/emoji-mart/dist-es/utils/shared-props.d.ts @@ -0,0 +1,83 @@ +import React = require('react'); + +import { EmojiData, EmojiSkin, CustomEmoji } from './emoji-index/nimble-emoji-index'; + +export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string; +export type EmojiSet = 'apple' | 'google' | 'twitter' | 'emojione' | 'messenger' | 'facebook'; +export type EmojiSheetSize = 16 | 20 | 32 | 64; + +export interface EmojiProps { + onOver?(emoji: EmojiData, e: React.MouseEvent): void; + onLeave?(emoji: EmojiData, e: React.MouseEvent): void; + onClick?(emoji: EmojiData, e: React.MouseEvent): void; + fallback?(emoji: EmojiData, props: EmojiProps): React.Component; + /** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */ + backgroundImageFn?: BackgroundImageFn; + native?: boolean; + forceSize?: boolean; + tooltip?: boolean; + /** defaults to 1 */ + skin?: EmojiSkin; + /** defaults to 64 */ + sheetSize?: EmojiSheetSize; + /** defaults to 52 */ + sheetColumns?: number; + /** defaults to 52 */ + sheetRows?: number; + /** defaults to 'apple' */ + set?: EmojiSet; + size: number; + emoji: string | EmojiData; + html?: boolean; + /** data is omitted here as it should be used for NimbleEmoji only - not emoji */ +} + +export type CategoryName = 'search' | 'recent' | 'people' | 'nature' | 'foods' | 'activity' | 'places' | 'objects' | 'symbols' | 'flags' | 'custom'; + +// tslint:disable-next-line interface-name +export interface I18n { + search: string; + categories: Record; + notfound: string; + skintext: string; +} + +export type PartialI18n = Partial & { categories: Partial }>; + +export interface CustomIcons { + categories: Record React.Component>; +} + +export interface PickerProps { + /** NOTE: default is not preventable */ + onClick?(emoji: EmojiData, e: React.MouseEvent): void; + onSelect?(emoji: EmojiData): void; + onSkinChange?(skin: EmojiSkin): void; + perLine?: number; + emojiSize?: number; + i18n?: PartialI18n; + style?: React.CSSProperties; + title?: string; + emoji?: string; + color?: string; + set?: EmojiSet; + skin?: EmojiSkin; + defaultSkin?: EmojiSkin; + native?: boolean; + backgroundImageFn?: BackgroundImageFn; + sheetSize?: EmojiSheetSize; + emojisToShowFilter?(emoji: EmojiData): boolean; + showPreview?: boolean; + showSkinTones?: boolean; + emojiTooltip?: boolean; + include?: CategoryName[]; + exclude?: CategoryName[]; + recent?: string[]; + autoFocus?: boolean; + /** NOTE: custom emoji are copied into a singleton object on every new mount */ + custom: CustomEmoji[]; + skinEmoji?: string; + notFound?(): React.Component; + notFoundEmoji?: string; + icons?: CustomIcons; +} diff --git a/types/emoji-mart/emoji-mart-tests.tsx b/types/emoji-mart/emoji-mart-tests.tsx index 7b7b8d0471..56b05453a9 100644 --- a/types/emoji-mart/emoji-mart-tests.tsx +++ b/types/emoji-mart/emoji-mart-tests.tsx @@ -1,4 +1,4 @@ -// Port of https://github.com/missive/emoji-mart/blob/master/src/components/emoji.js +// Port of https://github.com/missive/emoji-mart/blob/v2.8.0/stories/index.js import React = require('react'); diff --git a/types/emoji-mart/index.d.ts b/types/emoji-mart/index.d.ts index 22c17731f3..38acd9e021 100644 --- a/types/emoji-mart/index.d.ts +++ b/types/emoji-mart/index.d.ts @@ -1,9 +1,8 @@ -// Type definitions for emoji-mart 2.2 +// Type definitions for emoji-mart 2.8 // Project: https://github.com/missive/emoji-mart // Definitions by: Diogo Franco +// Nick Winans // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -// These definitions should work with 2.3, but the tests doesn't pass on 2.3. - export * from './dist-es'; diff --git a/types/emoji-mart/tsconfig.json b/types/emoji-mart/tsconfig.json index 6ecc944e77..d929a3cc01 100644 --- a/types/emoji-mart/tsconfig.json +++ b/types/emoji-mart/tsconfig.json @@ -20,11 +20,17 @@ "files": [ "index.d.ts", "dist-es/components/category.d.ts", - "dist-es/components/emoji.d.ts", + "dist-es/components/emoji/emoji.d.ts", + "dist-es/components/emoji/nimble-emoji.d.ts", "dist-es/components/index.d.ts", - "dist-es/components/picker.d.ts", - "dist-es/utils/emoji-index.d.ts", + "dist-es/components/picker/picker.d.ts", + "dist-es/components/picker/nimble-picker.d.ts", + "dist-es/utils/emoji-index/emoji-index.d.ts", + "dist-es/utils/emoji-index/nimble-emoji-index.d.ts", + "dist-es/utils/emoji-index/index.d.ts", + "dist-es/utils/data.d.ts", "dist-es/utils/frequently.d.ts", + "dist-es/utils/shared-props.d.ts", "dist-es/utils/store.d.ts", "dist-es/index.d.ts", "emoji-mart-tests.tsx" diff --git a/types/express-fileupload/index.d.ts b/types/express-fileupload/index.d.ts index 89331c066a..060476b109 100644 --- a/types/express-fileupload/index.d.ts +++ b/types/express-fileupload/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for express-fileupload 0.1 +// Type definitions for express-fileupload 0.4 // Project: https://github.com/richardgirges/express-fileupload#readme // Definitions by: Gintautas Miselis +// Sefa Ilkimen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -28,13 +29,16 @@ declare namespace fileUpload { encoding: string; mimetype: string; data: Buffer; + truncated: boolean; mv(path: string, callback: (err: any) => void): void; + mv(path: string): Promise; } interface Options { debug?: boolean; safeFileNames?: boolean; preserveExtension?: boolean | string | number; + abortOnLimit?: boolean; [property: string]: any; } } diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts index 9043cdaf0e..51f8964423 100644 --- a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver< SomeTestResult, SomeTestArgs, SomeTestContext ->(async (sources, args, context) => { +>(async (sources, args, context, info) => { // $ExpectType ReadonlyArray const verifySources = sources; // $ExpectType string const verifyArgs = args.someArg; // $ExpectType string const verifyContext = context.someContextProp; + // $ExpectType GraphQLResolveInfo + const verifyInfo = info; const result = await asyncBatchFunction(sources); return result; diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts index ea90a83555..9908b7082a 100644 --- a/types/graphql-resolve-batch/index.d.ts +++ b/types/graphql-resolve-batch/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 +import { GraphQLResolveInfo } from 'graphql'; + /** * Creates a GraphQL.js field resolver that batches together multiple resolves * together that share the *exact* same GraphQL field selection. @@ -45,5 +47,6 @@ export type ResolverFunction = ( export type BatchResolveFunction = ( sources: ReadonlyArray, args: TArgs, - context: TContext + context: TContext, + info: GraphQLResolveInfo ) => TReturn[] | Promise; diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 23aaf3608c..3d3b69b959 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger -// Rafael Souza Fijalkowski +// Definitions by: Rafael Souza Fijalkowski // Justin Simms // Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -3790,7 +3789,7 @@ export class Server extends Podium { * * path - the route path. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) */ - table(host?: string): Array<{settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}>; // TODO I am not sure if the ServerRoute is the object expected here + table(host?: string): RequestRoute[]; } /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/types/hapi/test/server/server-table.ts b/types/hapi/test/server/server-table.ts index ab14938be4..79726118b5 100644 --- a/types/hapi/test/server/server-table.ts +++ b/types/hapi/test/server/server-table.ts @@ -19,4 +19,11 @@ server.route({ server.start(); const table = server.table(); console.log(table); +console.log(table[0].method); +console.log(table[0].path); +console.log(table[0].vhost); +console.log(table[0].realm); +console.log(table[0].settings); +console.log(table[0].fingerprint); +console.log(table[0].auth); console.log('Server started at: ' + server.info.uri); diff --git a/types/inquirer/index.d.ts b/types/inquirer/index.d.ts index d00c037c71..5d976e896d 100644 --- a/types/inquirer/index.d.ts +++ b/types/inquirer/index.d.ts @@ -8,6 +8,7 @@ // Synarque // Justin Rockwood // Keith Kelly +// Junyoung Clare Jang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -116,12 +117,12 @@ declare namespace inquirer { * Receive the user input and should return true if the value is valid, and an error message (String) * otherwise. If false is returned, a default error message is provided. */ - validate?(input: string, answers?: T): boolean | string | Promise; + validate?(input: any, answers?: T): boolean | string | Promise; /** * Receive the user input and return the filtered value to be used inside the program. * The value returned will be added to the Answers hash. */ - filter?(input: string): string | Promise; + filter?(input: string): any; /** * Receive the user input and return the transformed value to be displayed to the user. The * transformation only impacts what is shown while editing. It does not impact the answers diff --git a/types/inquirer/inquirer-tests.ts b/types/inquirer/inquirer-tests.ts index 85a81d761e..4c8ba9491f 100644 --- a/types/inquirer/inquirer-tests.ts +++ b/types/inquirer/inquirer-tests.ts @@ -670,3 +670,17 @@ var questions = [ inquirer.createPromptModule({ output: process.stderr })(questions, function(answers) { console.log(JSON.stringify(answers, null, " ")); }); + +// Work with JS inquirer but rejected by typing. +inquirer.prompt([ + { + type: "input", + name: "listOfThings", + filter(value: string): string[] { + return ["abc", "def"]; + }, + validate(value: string[]): boolean { + return value.length > 0; + } + } +]); diff --git a/types/is-uuid/index.d.ts b/types/is-uuid/index.d.ts new file mode 100644 index 0000000000..f6e1f8626b --- /dev/null +++ b/types/is-uuid/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for is-uuid 1.0 +// Project: https://github.com/afram/is-uuid#readme +// Definitions by: André Thériault +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Returns true if the value is a v1 UUID + * @param value The value to test + */ +export function v1(value: string): boolean; + +/** + * Returns true if the value is a v2 UUID + * @param value The value to test + */ +export function v2(value: string): boolean; + +/** + * Returns true if the value is a v3 UUID + * @param value The value to test + */ +export function v3(value: string): boolean; + +/** + * Returns true if the value is a v4 UUID + * @param value The value to test + */ +export function v4(value: string): boolean; + +/** + * Returns true if the value is a v5 UUID + * @param value The value to test + */ +export function v5(value: string): boolean; + +/** + * Returns true if the value is a nil UUID + * @param value The value to test + */ +export function nil(value: string): boolean; + +/** + * Returns true for v1 - v5 UUID. Will return false for nil UUID + * @param value The value to test + */ +export function anyNonNil(value: string): boolean; diff --git a/types/is-uuid/is-uuid-tests.ts b/types/is-uuid/is-uuid-tests.ts new file mode 100644 index 0000000000..4e07b10905 --- /dev/null +++ b/types/is-uuid/is-uuid-tests.ts @@ -0,0 +1,10 @@ +import * as isUUID from 'is-uuid'; + +isUUID.v1('857b3f0a-a777-11e5-bf7f-feff819cdc9f'); +isUUID.v2('9a7b330a-a736-21e5-af7f-feaf819cdc9f'); +isUUID.v3('0a7b330a-a736-35ea-8f7f-feaf019cdc00'); +isUUID.v4('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.v5('5a2de30a-a736-5aea-8f7f-ad0f019cdc00'); + +isUUID.anyNonNil('c51c80c2-66a1-442a-91e2-4f55b4256a72'); +isUUID.nil('00000000-0000-0000-0000-000000000000'); diff --git a/types/is-uuid/tsconfig.json b/types/is-uuid/tsconfig.json new file mode 100644 index 0000000000..eec8e9597a --- /dev/null +++ b/types/is-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "is-uuid-tests.ts" + ] +} diff --git a/types/is-uuid/tslint.json b/types/is-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index 821e7ec162..b03a48dc6f 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -146,12 +146,24 @@ interface JQueryStatic { * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. * - * @param element_elementArray A DOM element to wrap in a jQuery object. - * An array containing a set of DOM elements to wrap in a jQuery object. + * @param element A DOM element to wrap in a jQuery object. * @see \`{@link https://api.jquery.com/jQuery/ }\` * @since 1.0 */ - (element_elementArray: T | ArrayLike): JQuery; + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (element: T): JQuery; + /** + * Return a collection of matched elements either found in the DOM based on passed argument(s) or created + * by passing an HTML string. + * + * @param elementArray An array containing a set of DOM elements to wrap in a jQuery object. + * @see \`{@link https://api.jquery.com/jQuery/ }\` + * @since 1.0 + */ + // Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810) + // tslint:disable-next-line:unified-signatures + (elementArray: T[]): JQuery; /** * Return a collection of matched elements either found in the DOM based on passed argument(s) or created * by passing an HTML string. diff --git a/types/jquery/jquery-tests.ts b/types/jquery/jquery-tests.ts index 309b1e2f89..417d2e7941 100644 --- a/types/jquery/jquery-tests.ts +++ b/types/jquery/jquery-tests.ts @@ -69,6 +69,12 @@ function JQueryStatic() { // $ExpectType JQuery $(); + // $ExpectType JQuery + $(new HTMLSelectElement()); + + // $ExpectType JQuery + $([new HTMLSelectElement()]); + // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432 function issue_19597_378218432() { const myDiv = $(document.createElement('div')); diff --git a/types/jsforce/connection.d.ts b/types/jsforce/connection.d.ts index fcf614eb92..e7fd593b01 100644 --- a/types/jsforce/connection.d.ts +++ b/types/jsforce/connection.d.ts @@ -10,8 +10,16 @@ import { Metadata } from './api/metadata'; import { Bulk } from './bulk'; import { Cache } from './cache' import { OAuth2, Streaming } from '.'; +import { HttpApiOptions } from './http-api' -export type Callback = (err: Error, result: T) => void; +export type Callback = (err: Error | null, result: T) => void; +// The type for these options was determined by looking at the usage +// of the options object in Connection.create and other methods +// go to http://jsforce.github.io/jsforce/doc/connection.js.html#line568 +// and search for options +export interface RestApiOptions { + headers?: { [x: string]: string } +} // These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49 // the oauth options can either be in the `oauth2` proeprty OR spread across the main connection @@ -93,24 +101,24 @@ export type ConnectionEvent = "refresh"; */ export abstract class BaseConnection extends EventEmitter { _baseUrl(): string; - request(info: RequestInfo | string, options?: Object, callback?: (err: Error, Object: object) => void): Promise; + request(info: RequestInfo | string, options?: HttpApiOptions, callback?: (err: Error, Object: object) => void): Promise; query(soql: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult) => void): Query>; queryMore(locator: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult) => void): Promise>; - create(type: string, records: Record | Array>, options?: Object, + create(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - insert(type: string, records: Record | Array>, options?: Object, + insert(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - retrieve(type: string, ids: string | string[], options?: Object, + retrieve(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: Record | Array>) => void): Promise<(Record | Array>)>; - update(type: string, records: Record | Array>, options?: Object, + update(type: string, records: Record | Array>, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | Array>) => void): Promise<(RecordResult | RecordResult[])>; - upsert(type: string, records: Record | Array>, extIdField: string, options?: Object, + upsert(type: string, records: Record | Array>, extIdField: string, options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - del(type: string, ids: string | string[], options?: Object, + del(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - delete(type: string, ids: string | string[], options?: Object, + delete(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; - destroy(type: string, ids: string | string[], options?: Object, + destroy(type: string, ids: string | string[], options?: RestApiOptions, callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>; describe$: { /** Returns a value from the cache if it exists, otherwise calls Connection.describe */ @@ -124,7 +132,8 @@ export abstract class BaseConnection extends EventEmitter { clear(): void; } describeGlobal(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise; - sobject(resource: string): SObject; + // we want any object to be accepted if the user doesn't decide to give an explicit type + sobject(resource: string): SObject; } export class Connection extends BaseConnection { diff --git a/types/jsforce/http-api.d.ts b/types/jsforce/http-api.d.ts new file mode 100644 index 0000000000..1986ce0c75 --- /dev/null +++ b/types/jsforce/http-api.d.ts @@ -0,0 +1,5 @@ +export interface HttpApiOptions { + responseType?: string; + transport?: object; + noContentResponse?: object +} diff --git a/types/jsforce/index.d.ts b/types/jsforce/index.d.ts index ddcb0d8260..d92677a5eb 100644 --- a/types/jsforce/index.d.ts +++ b/types/jsforce/index.d.ts @@ -6,7 +6,7 @@ // Tim Noonan // Abraham White // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 export * from './api/analytics'; export * from './api/chatter'; diff --git a/types/jsforce/jsforce-tests.ts b/types/jsforce/jsforce-tests.ts index 8eb97aebc7..8e572448b4 100644 --- a/types/jsforce/jsforce-tests.ts +++ b/types/jsforce/jsforce-tests.ts @@ -4,12 +4,9 @@ import * as express from 'express'; import * as glob from 'glob'; import * as sf from 'jsforce'; - -export interface DummyRecord { - thing: boolean; - other: number; - person: string; -} +import { RecordReference, Record } from 'jsforce/record'; +import { SObject } from 'jsforce/salesforce-object'; +import { RecordResult } from 'jsforce/record-result'; const salesforceConnection: sf.Connection = new sf.Connection({ instanceUrl: '', @@ -20,7 +17,390 @@ const salesforceConnection: sf.Connection = new sf.Connection({ }, }); -salesforceConnection.sobject("Dummy").select(["thing", "other"]); +async function testSObject(connection: sf.Connection) { + interface DummyRecord { + thing: boolean; + other: number; + person: string; + } + + const dummySObject: SObject = connection.sobject('Dummy'); + + // currently untyped, but some future change may make this stricter + const restApiOptions = { + headers: { Bearer: 'I have no idea what this wants' } + }; + + { // Test SObject.record + // $ExpectType RecordReference + dummySObject.record('50130000000014C'); + } + + { // Test SObject.retrieve + // with single id + // $ExpectType Record + await dummySObject.retrieve('50130000000014C'); + // with single id and rest api options + // $ExpectType Record + await dummySObject.retrieve('50130000000014C', restApiOptions); + + // with single id and callback + dummySObject.retrieve('50130000000014C', restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType Record + }); + + // with ids array + // $ExpectType Record[] + await dummySObject.retrieve(['IIIIDDD']); + // with ids array and rest api options + // $ExpectType Record[] + await dummySObject.retrieve(['IIIIDDD'], restApiOptions); + + // with ids array and callback + dummySObject.retrieve(['50130000000014C'], restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType Record[] + }); + + salesforceConnection.sobject("ContentVersion").retrieve("world", { + test: "test" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType any + }); + } + + { // Test SObject.update + // if we require that records have an id field this will fail + // //$ExpectError + await dummySObject.update({ thing: false }); + + // If we require that the records have an Id field + // await dummySObject.update({ thing: false, Id: 'asdf' }); // $ExpectType RecordResult + + // invalid field + // $ExpectError + await dummySObject.update({ asdf: false }); + + // with rest api options + // $ExpectType RecordResult + await dummySObject.update({ thing: false }, restApiOptions); + + // with callback + dummySObject.update({ thing: false }, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult + }); + + dummySObject.update({ thing: false }, restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult + }); + + // with multiple records + // $ExpectType RecordResult[] + await dummySObject.update([{ thing: false }]); + + // with multiple records and api options + // $ExpectType RecordResult[] + await dummySObject.update([{ thing: false }], restApiOptions); + + // with multiple records and callback + dummySObject.update([{ thing: false }], restApiOptions, (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + dummySObject.update([{ thing: false }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.updated + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated(new Date(), new Date()); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated(new Date(), 'hi'); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated('hi', new Date()); + + // $ExpectType UpdatedRecordsInfo + await dummySObject.updated('hi', 'hi'); + + dummySObject.updated(new Date(), 'hi', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType UpdatedRecordsInfo + }); + } + + { // Test SObject.upsert + const updateData = { + Id: 'Some ID', + thing: true, + other: 1, + person: 'hi' + }; + // $ExpectType RecordResult + await dummySObject.upsert(updateData, 'Id'); + + // $ExpectType RecordResult + await dummySObject.upsert(updateData, 'Id', restApiOptions); + + // $ExpectType RecordResult[] + await dummySObject.upsert([updateData], 'Id'); + + // $ExpectType RecordResult[] + await dummySObject.upsert([updateData], 'Id', restApiOptions); + + dummySObject.upsert(updateData, 'Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.upsert(updateData, 'Id', restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.upsert([updateData], 'Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + dummySObject.upsert([updateData], 'Id', restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.find + } + + { // Test SObject.findOne + salesforceConnection.sobject("ContentVersion").findOne({ Id: '' }, (err, contentVersion) => { + err; // $ExpectType Error | null + contentVersion; // $ExpectType any + }); + } + + { // Test SObject.select + + dummySObject.select(["thing", "other"]); + + // note the following should never compile: + // $ExpectError + dummySObject.select(["lol"]); + } + + { // Test SObject.create + // $ExpectType RecordResult + await dummySObject.create({ + thing: true, + other: 1, + person: 'hi' + }); + + // $ExpectType RecordResult + await dummySObject.create({ + thing: true, + other: 1, + person: 'hi' + }, restApiOptions); + + // $ExpectType RecordResult[] + await dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }]); + + // $ExpectType RecordResult[] + await dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], restApiOptions); + + dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + dummySObject.create([{ + thing: true, + other: 1, + person: 'hi' + }], restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + + salesforceConnection.sobject("Account").create({ + Name: "Test Acc 2", + BillingStreet: "Maplestory street", + BillingPostalCode: "ME4 666" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + // callback and rest api options + salesforceConnection.sobject("ContentVersion").create({ + OwnerId: '', + Title: 'hello', + PathOnClient: './hello-world.jpg', + VersionData: '{ Test: Data }' + }, restApiOptions, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + salesforceConnection.sobject("ContentDocumentLink").create({ + ContentDocumentId: '', + LinkedEntityId: '', + ShareType: "I" + }, (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + } + + { // Test SObject.createBulk + // $ExpectType Batch + dummySObject.createBulk(); + // $ExpectType Batch + dummySObject.createBulk('hi.csv'); + // $ExpectType Batch + dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.createBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.deleteBulk and aliases + // $ExpectType Batch + dummySObject.deleteBulk(); + // $ExpectType Batch + dummySObject.deleteBulk('hi.csv'); + // $ExpectType Batch + dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.deleteBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + // $ExpectType Batch + dummySObject.destroyBulk(); + // $ExpectType Batch + dummySObject.destroyBulk('hi.csv'); + // $ExpectType Batch + dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.destroyBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.deleteHardBulk and aliases + // $ExpectType Batch + dummySObject.deleteHardBulk(); + // $ExpectType Batch + dummySObject.deleteHardBulk('hi.csv'); + // $ExpectType Batch + dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.deleteHardBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + + // $ExpectType Batch + dummySObject.destroyHardBulk(); + // $ExpectType Batch + dummySObject.destroyHardBulk('hi.csv'); + // $ExpectType Batch + dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]); + // $ExpectType Batch + dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + dummySObject.destroyHardBulk('hi.csv', (err, res) => { + err; // $ExpectType Error | null + res; // $ExpectType RecordResult[] + }); + } + + { // Test SObject.destroy and aliases + // $ExpectType RecordResult + await dummySObject.del('Id'); + // $ExpectType RecordResult + await dummySObject.destroy('Id'); + // $ExpectType RecordResult + await dummySObject.delete('Id'); + + // $ExpectType RecordResult[] + await dummySObject.del(['Id']); + // $ExpectType RecordResult[] + await dummySObject.destroy(['Id']); + // $ExpectType RecordResult[] + await dummySObject.delete(['Id']); + + dummySObject.del('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + dummySObject.destroy('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + dummySObject.delete('Id', (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult + }); + + dummySObject.del(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + dummySObject.destroy(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + dummySObject.delete(['Id'], (err, ret) => { + err; // $ExpectType Error | null + ret; // $ExpectType RecordResult[] + }); + } +} const requestInfo: sf.RequestInfo = { body: '', @@ -38,51 +418,6 @@ const queryOptions: sf.ExecuteOptions = { }; salesforceConnection.query('SELECT Id, Name FROM Account', queryOptions); -// note the following should never compile: -// salesforceConnection.sobject("Dummy").select(["lol"]); - -salesforceConnection.sobject("Account").create({ - Name: "Test Acc 2", - BillingStreet: "Maplestory street", - BillingPostalCode: "ME4 666" -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").create({ - OwnerId: '', - Title: 'hello', - PathOnClient: './hello-world.jpg', - VersionData: '{ Test: Data }' -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").retrieve("world", { - test: "test" -}, (err: Error, ret) => { - if (err) { - return; - } -}); - -salesforceConnection.sobject("ContentVersion").findOne({ Id: '' }, (err, contentVersion) => { -}); - -salesforceConnection.sobject("ContentDocumentLink").create({ - ContentDocumentId: '', - LinkedEntityId: '', - ShareType: "I" -}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => { - if (err || !Array.isArray(ret) && !ret.success) { - return; - } -}); - sf.Date.YESTERDAY; salesforceConnection.sobject('Coverage__c') @@ -230,7 +565,7 @@ async function testChatter(conn: sf.Connection): Promise { }, feedElementType: 'FeedItem', subjectId: 'me' - }, (err: Error, result: any) => { + }, (err: Error | null, result: any) => { if (err) { throw err; } @@ -242,7 +577,7 @@ async function testChatter(conn: sf.Connection): Promise { text: 'This is new comment on the post' }] } - }, (err: Error, result: any) => { + }, (err: Error | null, result: any) => { if (err) { throw err; } @@ -366,13 +701,15 @@ async function testDescribe() { object.fields.forEach(field => { const type: sf.FieldType = field.type; // following should never compile - // const fail = type === 'hey' + // $ExpectError + const fail = type === 'hey'; const isString = type === 'string'; }); // following should never compile (if StrictNullChecks is on) - // object.keyPrefix.length; + // $ExpectError + object.keyPrefix.length; console.log(`${sobject.name} Label: `, object.label); diff --git a/types/jsforce/quick-action.d.ts b/types/jsforce/quick-action.d.ts new file mode 100644 index 0000000000..a67f4d4e08 --- /dev/null +++ b/types/jsforce/quick-action.d.ts @@ -0,0 +1,52 @@ +import { Callback } from './connection'; +import { Record } from './record'; + +export class QuickAction { + /** + * Retrieve default field values in the action for the given record + * @param contextId Id of record + * @param callback Callback function + */ + defaultValues(contextId: string, callback?: Callback): Promise; + /** Retrieve default field values in the action */ + defaultValues(callback?: Callback): Promise; + /** + * Describe the action's information (including layout, etc.) + * @param callback Callback function + */ + describe(callback?: Callback): Promise; + /** + * Execute the action for given context id and record information + * @param contextId Context record ID of the action + * @param record Input record information for the action + * @param callback Callback function + */ + execute(contextId: string, record: Record, callback?: Callback): Promise; +} + +// TODO: figure out the actual shape of this. the docs don't have it +export type QuickActionResult = object; + +export interface QuickActionInfo { + /** Type of the action (e.g. Create, Update, Post, LogACall) */ + type: string; + /** Name of the action */ + name: string; + /** Label of the action */ + label: string; + /** Endpoint URL information of the action */ + urls: object; +} + +export interface QuickActionDescribeInfo { + /** Object type used for the action */ + contextSobjectType: string; + /** Object type of the action to target */ + targetSobjectType: string; + /** Field name in the target object which refers parent(context) object record ID */ + targetParentField: string; + /** Record type of the targeted record */ + targetRecordTypeId: string; + /** Layout sections that comprise an action */ + layout: object; +} diff --git a/types/jsforce/salesforce-object.d.ts b/types/jsforce/salesforce-object.d.ts index ab3e398891..a2f1c5dffd 100644 --- a/types/jsforce/salesforce-object.d.ts +++ b/types/jsforce/salesforce-object.d.ts @@ -5,74 +5,103 @@ import { DescribeSObjectResult } from './describe-result'; import { Query } from './query'; import { Record, RecordReference } from './record'; import { RecordResult } from './record-result'; -import { Connection } from './connection'; +import { Connection, RestApiOptions, Callback } from './connection'; import { SalesforceId } from './salesforce-id'; import { Batch, BatchResultInfo } from './batch'; +import { QuickAction, QuickActionInfo } from './quick-action'; export class SObject { record(id: SalesforceId): RecordReference; - retrieve(id: SalesforceId, options?: Object, callback?: (err: Error, record: Record) => void): Promise>; - retrieve(ids: SalesforceId[], options?: Object, callback?: (err: Error, ret: Array>) => void): Promise>>; - update(record: Partial, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; - update(records: Array>, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; - upsert(records: Record, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise; - upsert(records: Array>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise; - upsertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[] | BatchResultInfo[]) => void): Batch; + retrieve(id: SalesforceId, callback?: Callback>): Promise>; + retrieve(id: SalesforceId, options?: object, callback?: Callback>): Promise>; + retrieve(ids: SalesforceId[], callback?: Callback>>): Promise>>; + retrieve(ids: SalesforceId[], options?: object, callback?: Callback>>): Promise>>; + // Should update require that the record Id field be provided? + update(record: Partial, callback?: Callback): Promise; + update(record: Partial, options?: RestApiOptions, callback?: Callback): Promise; + update(records: Array>, callback?: Callback): Promise; + update(records: Array>, options?: RestApiOptions, callback?: Callback): Promise; + // should input really be optional? the documentation says so, but how can you actually update without it? + updateBulk(input?: Record[] | stream.Stream | string, callback?: Callback): Batch; + updated(start: string | Date, end: string | Date, callback?: Callback): Promise; + upsert(records: Record, extIdField: string, callback?: Callback): Promise; + upsert(records: Record, extIdField: string, options?: RestApiOptions, callback?: Callback): Promise; + upsert(records: Array>, extIdField: string, callback?: Callback): Promise; + upsert(records: Array>, extIdField: string, options?: RestApiOptions, callback?: Callback): Promise; + upsertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; - find(query?: any, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query; - find(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query; + find(query?: object | string, callback?: Callback>>): Query>>; + find(query?: object | string, fields?: Object | string[] | string, callback?: Callback>>): Query>>; + find(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback>>): Query>>; - findOne(query?: any, callback?: (err: Error, ret: T) => void): Query; - findOne(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query; - findOne(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): Query; + findOne(query?: object | string, callback?: Callback>): Query>; + findOne(query?: object | string, fields?: Object | string[] | string, callback?: Callback>): Query>; + findOne(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback>): Query>; approvalLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */ - (callback?: (layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo; + (callback?: Callback): ApprovalLayoutInfo; clear(): void; } - approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise; - bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch; + approvalLayouts(callback?: Callback): Promise; + bulkload(operation: string, options?: { extIdField?: string }, input?: Array> | stream.Stream | string, callback?: Callback): Batch; compactLayouts$: { /** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */ - (callback?: CompactLayoutInfo): CompactLayoutInfo; + (callback?: Callback): CompactLayoutInfo; clear(): void; } - compactLayouts(callback?: CompactLayoutInfo): Promise; - count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise; - create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; - createBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - del(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - delete(ids: string | string[], callback?: (err: Error, ret: any) => void): void; - deleteBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - destroyBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - destroyHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise; - deleteHardBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; - describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise; + compactLayouts(callback?: Callback): Promise; + count(conditions?: object | string, callback?: Callback): Query; + create(record: T, options?: RestApiOptions, callback?: Callback): Promise; + create(record: T, callback?: Callback): Promise; + create(record: Array, options?: RestApiOptions, callback?: Callback): Promise; + create(record: Array, callback?: Callback): Promise; + createBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + del(id: string, callback?: Callback): Promise; + del(ids: string[], callback?: Callback): Promise; + destroy(id: string, callback?: Callback): Promise; + destroy(ids: string[], callback?: Callback): Promise; + delete(id: string, callback?: Callback): Promise; + delete(ids: string[], callback?: Callback): Promise; + deleteBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + destroyBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + destroyHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + deleted(start: Date | string, end: Date | string, callback?: Callback): Promise; + deleteHardBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; + describe(callback?: Callback): Promise; describe$: { /** Returns a value from the cache if it exists, otherwise calls SObject.describe */ - (callback?: (err: Error, ret: DescribeSObjectResult) => void): DescribeSObjectResult; + (callback?: Callback): DescribeSObjectResult; clear(): void; } - insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise; - insertBulk(input?: Array> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch; + insert(record: Record, callback?: Callback): Promise; + insert(records: Array>, callback?: Callback): Promise; + insertBulk(input?: Array> | stream.Stream | string, callback?: Callback): Batch; /** Returns a value from the cache if it exists, otherwise calls SObject.layouts */ layouts$: { - (layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): LayoutInfo; + (layoutName?: string, callback?: Callback): LayoutInfo; clear(): void; } - layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise; + layouts(layoutName?: string, callback?: Callback): Promise; listview(id: string): ListView; - listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise; + listviews(callback?: Callback): Promise; quickAction(actionName: string): QuickAction; - quickActions(callback?: (err: Error, info: any) => void): Promise; - recent(callback?: (err: Error, ret: RecordResult) => void): Promise; - select(callback?: (err: Error, ret: T[]) => void): Query; + quickActions(callback?: Callback): Promise; + recent(callback?: Callback): Promise; + select(callback?: Callback): Query; // TODO:use a typed pluck to turn `fields` into a subset of T's fields so that the output is slimmed down appropriately - select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: (err: Error, ret: Array>) => void): Query>>; + select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: Callback>>): Query>>; +} + +export interface FindOptions { + limit?: number; + offset?: number; + skip?: number; +} + +export interface UpdatedRecordsInfo { + latestDateCovered: string; + ids: string[]; } export interface ApprovalLayoutInfo { @@ -104,4 +133,5 @@ export class ListView { } export class ListViewsInfo { } -export class QuickAction { } +// TODO: Remove this export +export { QuickAction } // for compatibility if anyone had imported it from this file diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index c1fb224fa0..54dece1068 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -536,6 +536,7 @@ declare namespace Knex { acquireConnectionTimeout?: number; useNullAsDefault?: boolean; searchPath?: string | string[]; + asyncStackTraces?: boolean; } interface ConnectionConfig { diff --git a/types/moment-duration-format/index.d.ts b/types/moment-duration-format/index.d.ts index 1716d55d83..760b7b8263 100644 --- a/types/moment-duration-format/index.d.ts +++ b/types/moment-duration-format/index.d.ts @@ -90,3 +90,7 @@ declare module "moment" { type TemplateFunction = ((this: DurationFormatSettings) => string); } + +declare function momentDurationFormatSetup(_moment: typeof moment): void; + +export = momentDurationFormatSetup; diff --git a/types/moment-duration-format/test/module-tests.ts b/types/moment-duration-format/test/module-tests.ts new file mode 100644 index 0000000000..9178e9c414 --- /dev/null +++ b/types/moment-duration-format/test/module-tests.ts @@ -0,0 +1,4 @@ +import moment = require("moment"); +import momentDurationFormatSetup = require("moment-duration-format"); + +momentDurationFormatSetup(moment); diff --git a/types/moment-duration-format/tsconfig.json b/types/moment-duration-format/tsconfig.json index 997b0f907e..b41c97ed28 100644 --- a/types/moment-duration-format/tsconfig.json +++ b/types/moment-duration-format/tsconfig.json @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", - "moment-duration-format-tests.ts" + "moment-duration-format-tests.ts", + "test/module-tests.ts" ] } \ No newline at end of file diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index c773c85a28..dd2d5ca394 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -1,125 +1,220 @@ -// Type definitions for N3 +// Type definitions for N3 1.0 // Project: https://github.com/RubenVerborgh/N3.js // Definitions by: Fred Eisele +// Ruben Taelman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 /// - import * as fs from "fs"; import * as stream from "stream"; +import * as RDF from "rdf-js"; +import { EventEmitter } from "events"; -declare namespace N3 { - - type ErrorCallback = (err: Error, result: any) => void; - - interface Prefixes { - [key: string]: string; - } - - interface LiteralValue { - value: string | number; - } - - interface Triple { - subject: string, - predicate: string, - object: string, - graph?: string - } - - interface BlankTriple { - predicate: string, - object: string - } - - - interface ParserConstructor { - new (options?: ParserOptions): N3Parser; - (options?: ParserOptions): N3Parser; - } - const Parser: ParserConstructor; - - interface StreamParserConstructor { - new (options?: ParserOptions): N3StreamParser; - (options?: ParserOptions): N3StreamParser; - } - const StreamParser: StreamParserConstructor; - - interface ParserOptions { - format?: string, - prefixes?: string[] - } - - interface ParseCallback { - (error: Error, triple: Triple, prefixes: Prefixes): void; - } - - interface Logger { - (message?: any, ...optionalParams: any[]): void; - } - interface N3Parser { - parse(input: string, callback: ParseCallback): void; - parse(subject: string, predicate: string, object: string): void; - parse(triple: Triple): void; - parse(stream: fs.ReadStream, log: Logger): void; - } - - interface N3StreamParser extends N3Parser, fs.WriteStream { - pipe(consumer: T): T; - } - - - interface WriterConstructor { - new (options?: WriterOptions): N3Writer; - (options?: WriterOptions): N3Writer; - - new (fd: any, options?: WriterOptions): N3Writer; - (fd: any, options?: WriterOptions): N3Writer; - } - const Writer: WriterConstructor; - - interface N3Writer { - addTriple(subject: string, predicate: string, object: string): void; - addTriple(subject: string, predicate: string, object: string[]): void; - addTriple(triple: Triple): void; - end(err?: ErrorCallback, result?: any): void; - blank(ns: string, name: string): string; - blank(triple: BlankTriple[]): string; - list(triple: string[]): string[]; - } - - function StreamWriter(options: WriterOptions): N3StreamWriter; - - interface N3StreamWriter extends N3Writer { - pipe(consumer: NodeJS.WritableStream): void; - pipe(consumer: stream.Writable): void; - } - - interface WriterOptions { - format?: string, - prefixes?: Prefixes - } - - interface N3StoreWriter extends N3Writer { - find(subject: string, predicate: string | null, object: string | null): Triple[]; - } - function Store(): N3StoreWriter; - - namespace Util { - function createLiteral(value: any): string; - function createLiteral(value: any, type: string): string; - - function isIRI(value: string): boolean; - function isLiteral(value: string): boolean; - function getLiteralValue(value: string): string; - function getLiteralLanguage(value: string): string; - function getLiteralType(value: string): string; - function isBlank(value: string): boolean; - function isPrefixedName(name: string): boolean; - function expandPrefixedName(name: string, prefixes: Prefixes): string; - } +export interface Prefixes { + [key: string]: RDF.NamedNode; } -export = N3; +export class Term implements RDF.Term { + termType: "NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph"; + id: string; + value: string; + constructor(iri: string); + toJSON(): string; + equals(other: RDF.Term): boolean; + static subclass(type: any): void; +} +export class NamedNode extends Term implements RDF.NamedNode { + termType: "NamedNode"; + value: string; + constructor(iri: string); +} + +export class BlankNode extends Term implements RDF.BlankNode { + static nextId: number; + termType: "BlankNode"; + value: string; + constructor(name: string); +} + +export class Variable extends Term implements RDF.Variable { + termType: "Variable"; + value: string; + constructor(name: string); +} + +export class Literal extends Term implements RDF.Literal { + static readonly langStringDatatype: NamedNode; + termType: "Literal"; + value: string; + language: string; + datatype: RDF.NamedNode; + datatypeString: string; + constructor(id: string); +} + +export class DefaultGraph extends Term implements RDF.DefaultGraph { + termType: "DefaultGraph"; + value: ""; + constructor(); +} + +export class Quad implements RDF.Quad { + constructor(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term); + subject: RDF.Term; + predicate: RDF.Term; + object: RDF.Term; + graph: RDF.Term; + equals(other: RDF.Quad): boolean; + toJSON(): string; +} + +export class Triple extends Quad implements RDF.Triple {} + +export namespace DataFactory { + function namedNode(value: string): RDF.NamedNode; + function blankNode(value?: string): RDF.BlankNode; + function literal(value: string | number, languageOrDatatype?: string | RDF.NamedNode): RDF.Literal; + function variable(value: string): RDF.Variable; + function defaultGraph(): RDF.DefaultGraph; + function triple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term): RDF.Quad; + function quad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): RDF.Quad; +} + +export type ErrorCallback = (err: Error, result: any) => void; +export type QuadCallback = (result: Quad) => void; +export type QuadPredicate = (result: Quad) => boolean; + +export type OTerm = RDF.Term | string | null; + +export type Logger = (message?: any, ...optionalParams: any[]) => void; + +export interface BlankTriple { + predicate: RDF.Term; + object: RDF.Term; +} + +export interface ParserConstructor { + new (options?: ParserOptions): N3Parser; + (options?: ParserOptions): N3Parser; +} +export const Parser: ParserConstructor; + +export interface ParserOptions { + format?: string; + prefixes?: string[]; + factory?: RDF.DataFactory; + baseIRI?: string; +} + +export type ParseCallback = (error: Error, quad: Quad, prefixes: Prefixes) => void; + +export interface N3Parser { + parse(input: string, callback: ParseCallback): void; +} + +export interface StreamParserConstructor { + new (options?: ParserOptions): N3StreamParser; + (options?: ParserOptions): N3StreamParser; +} +export const StreamParser: StreamParserConstructor; + +export interface N3StreamParser extends RDF.Stream, NodeJS.WritableStream, RDF.Sink { + // Below are the NodeJS.ReadableStream methods, + // we can not extend the interface directly, + // as `read` clashes with RDF.Sink. + readable: boolean; + // read(size?: number): string | Buffer; // Overwritten by RDF.Stream + setEncoding(encoding: string | null): void; + pause(): this; + resume(): this; + isPaused(): boolean; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: NodeJS.WritableStream | RDF.Stream): void; + unshift(chunk: string | Buffer): void; + wrap(oldStream: NodeJS.ReadableStream | RDF.Stream): NodeJS.ReadableStream; +} + +export interface WriterOptions { + format?: string; + prefixes?: Prefixes; +} + +export interface WriterConstructor { + new (options?: WriterOptions): N3Writer; + new (fd: any, options?: WriterOptions): N3Writer; + (options?: WriterOptions): N3Writer; + (fd: any, options?: WriterOptions): N3Writer; +} +export const Writer: WriterConstructor; + +export interface N3Writer { + quadToString(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): string; + quadsToString(quads: RDF.Quad[]): string; + addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addQuad(quad: RDF.Quad): void; + addQuads(quads: RDF.Quad[]): void; + end(err?: ErrorCallback, result?: string): void; + blank(predicate: RDF.Term, object: RDF.Term): RDF.Term; + blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): RDF.Term; + list(triple: RDF.Term[]): RDF.Term[]; +} + +export interface StreamWriterConstructor { + new (options?: WriterOptions): N3StreamWriter; + new (fd: any, options?: WriterOptions): N3StreamWriter; + (options?: WriterOptions): N3StreamWriter; + (fd: any, options?: WriterOptions): N3StreamWriter; +} +export const StreamWriter: StreamWriterConstructor; + +export interface N3StreamWriter extends NodeJS.ReadWriteStream, RDF.Source {} + +export interface N3Store extends RDF.Sink { + readonly size: number; + addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + addQuad(quad: RDF.Quad): void; + addQuads(quads: RDF.Quad[]): void; + removeQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; + removeQuad(quad: RDF.Quad): void; + removeQuads(quads: RDF.Quad[]): void; + getQuads(subject: OTerm, predicate: OTerm, object: OTerm | OTerm[], graph: OTerm): Quad[]; + countQuads(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number; + forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void; + every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void; + getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void; + getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[]; + forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; + getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; + forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; + createBlankNode(suggestedName?: string): BlankNode; + + // match, removeMatches and deleteGraph are missing for full RDF.Store adherence + remove(stream: stream.Stream): EventEmitter; +} +export interface StoreConstructor { + new (triples?: RDF.Quad[], options?: StoreOptions): N3Store; + (triples?: RDF.Quad[], options?: StoreOptions): N3Store; +} +export const Store: StoreConstructor; + +export interface StoreOptions { + factory?: RDF.DataFactory; +} + +export namespace Util { + function isNamedNode(value: RDF.Term | null): boolean; + function isBlankNode(value: RDF.Term | null): boolean; + function isLiteral(value: RDF.Term | null): boolean; + function isVariable(value: RDF.Term | null): boolean; + function isDefaultGraph(value: RDF.Term | null): boolean; + function inDefaultGraph(value: RDF.Quad): boolean; + function prefix(iri: string, factory?: RDF.DataFactory): (suffix: string) => RDF.NamedNode; + function prefixes(defaultPrefixes: Prefixes, factory?: RDF.DataFactory): (iri: string) => (suffix: string) => RDF.NamedNode; +} diff --git a/types/n3/n3-tests.ts b/types/n3/n3-tests.ts index d3c664c61e..367b602c8a 100644 --- a/types/n3/n3-tests.ts +++ b/types/n3/n3-tests.ts @@ -1,10 +1,10 @@ import * as N3 from "n3"; +import * as RDF from "rdf-js"; import * as fs from "fs"; import * as stream from "stream"; function test_serialize() { - - var writer: N3.N3Writer = N3.Writer( + const writer: N3.N3Writer = new N3.Writer( { format: "ttl", prefixes: { @@ -13,169 +13,171 @@ function test_serialize() { g: "http://base.google.com/ns/1.0" } }); - writer.addTriple({ - subject: "subject-name", - predicate: "predicate-name", - object: N3.Util.createLiteral(12) - }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode("subject-name"), + N3.DataFactory.namedNode("predicate-name"), + N3.DataFactory.literal(12) + )); writer.end((error, result) => { console.log(`result ${result}`); }); } -/** +/* The following tests are taken from ... https://github.com/RubenVerborgh/N3.js/blob/master/README.md */ function test_doc_rdf_to_triples_1() { - var parser = N3.Parser(); - parser.parse('@prefix c: .\n' + - 'c:Tom a c:Cat.\n' + - 'c:Jerry a c:Mouse;\n' + - ' c:smarterThan c:Tom.', - function (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) { - if (triple) - console.log(triple.subject, triple.predicate, triple.object, '.'); + const parser: N3.N3Parser = new N3.Parser(); + parser.parse(`@prefix c: . + c:Tom a c:Cat. + c:Jerry a c:Mouse; + c:smarterThan c:Tom.`, + (error: Error, quad: RDF.Quad, prefixes: N3.Prefixes) => { + if (quad) + console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.'); else - console.log("# That's all, folks!", prefixes) + console.log("# That's all, folks!", prefixes); }); } function test_doc_rdf_to_triples_2() { - var parser1 = N3.Parser({ format: 'N-Triples' }); - var parser2 = N3.Parser({ format: 'application/trig' }); + const parser1: N3.N3Parser = new N3.Parser({ format: 'N-Triples' }); + const parser2: N3.N3Parser = new N3.Parser({ format: 'application/trig' }); // Notation3 (N3) is supported only through the format argument: - var parser3 = N3.Parser({ format: 'N3' }); - var parser4 = N3.Parser({ format: 'Notation3' }); - var parser5 = N3.Parser({ format: 'text/n3' }); + const parser3: N3.N3Parser = N3.Parser({ format: 'N3' }); + const parser4: N3.N3Parser = N3.Parser({ format: 'Notation3' }); + const parser5: N3.N3Parser = N3.Parser({ format: 'text/n3' }); } function test_doc_rdf_stream_to_triples_1() { - var parser = N3.Parser(); - var rdfStream = fs.createReadStream('cartoons.ttl'); - parser.parse(rdfStream, console.log); + const parser: N3.N3Parser = new N3.Parser(); + parser.parse('abc', console.log); - var streamParser = N3.StreamParser(); - var rdfStream = fs.createReadStream('cartoons.ttl'); - rdfStream.pipe(streamParser); + const streamParser: N3.N3StreamParser = N3.StreamParser(); + const quad: RDF.Quad = streamParser.read(); + const rdfStream = fs.createReadStream('cartoons.ttl'); + const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser); streamParser.pipe(new class SlowConsumer extends stream.Writable { constructor() { super({ objectMode: true }); - this._write = function (triple, encoding, done) { - console.log(triple); + this._write = (quad: RDF.Quad, encoding, done) => { + console.log(quad); setTimeout(done, 1000); }; } - }); + }()); } function test_doc_from_triples_to_string() { - var writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); - writer.addTriple('http://example.org/cartoons#Tom', - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple({ - subject: 'http://example.org/cartoons#Tom', - predicate: 'http://example.org/cartoons#name', - object: '"Tom"' - }); - writer.end(function (error, result) { console.log(result); }); + const writer: N3.N3Writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat') + )); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#name'), + N3.DataFactory.literal('Tom'), + )); + writer.end((error, result: string) => { console.log(result); }); - var writer1 = N3.Writer({ format: 'N-Triples' }); - var writer2 = N3.Writer({ format: 'application/trig' }); + const writer1: N3.N3Writer = N3.Writer({ format: 'N-Triples' }); + const writer2: N3.N3Writer = N3.Writer({ format: 'application/trig' }); } function test_doc_from_triples_to_rdf_stream() { - var writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } }); - writer.addTriple('http://example.org/cartoons#Tom', - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple({ - subject: 'http://example.org/cartoons#Tom', - predicate: 'http://example.org/cartoons#name', - object: '"Tom"' - }); + const writer: N3.N3Writer = new N3.Writer(process.stdout, { prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } }); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat'), + )); + writer.addQuad(N3.DataFactory.quad( + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#name'), + N3.DataFactory.literal('Tom'), + )); writer.end(); } function test_doc_from_triple_stream_to_rdf_stream() { - var streamParser = new N3.StreamParser(), - inputStream = fs.createReadStream('cartoons.ttl'), - streamWriter = /* new */ N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } }); + const streamParser: N3.N3StreamParser = new N3.StreamParser(); + const inputStream = fs.createReadStream('cartoons.ttl'); + const streamWriter: N3.N3StreamWriter = new N3.StreamWriter({ prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } }); inputStream.pipe(streamParser); streamParser.pipe(streamWriter); streamWriter.pipe(process.stdout); } function test_doc_blank_nodes_and_lists() { - var writer = N3.Writer({ + const writer: N3.N3Writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#', foaf: 'http://xmlns.com/foaf/0.1/' } }); - writer.addTriple(writer.blank('http://xmlns.com/foaf/0.1/givenName', '"Tom"@en'), - 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - 'http://example.org/cartoons#Cat'); - writer.addTriple('http://example.org/cartoons#Jerry', - 'http://xmlns.com/foaf/0.1/knows', + writer.addQuad(writer.blank(N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'), N3.DataFactory.literal('Tom', 'en')), + N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + N3.DataFactory.namedNode('http://example.org/cartoons#Cat')); + writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Jerry'), + N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/knows'), writer.blank([{ - predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', - object: 'http://example.org/cartoons#Cat' + predicate: N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), + object: N3.DataFactory.namedNode('http://example.org/cartoons#Cat') }, { - predicate: 'http://xmlns.com/foaf/0.1/givenName', - object: '"Tom"@en', + predicate: N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'), + object: N3.DataFactory.literal('Tom', 'en'), }])); - writer.addTriple('http://example.org/cartoons#Mammy', - 'http://example.org/cartoons#hasPets', + writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Mammy'), + N3.DataFactory.namedNode('http://example.org/cartoons#hasPets'), writer.list([ - 'http://example.org/cartoons#Tom', - 'http://example.org/cartoons#Jerry' + N3.DataFactory.namedNode('http://example.org/cartoons#Tom'), + N3.DataFactory.namedNode('http://example.org/cartoons#Jerry') ])); - writer.end(function (error, result) { console.log(result); }); + writer.end((error, result) => { console.log(result); }); } function test_doc_storing() { - var store = N3.Store(); - store.addTriple('http://ex.org/Pluto', 'http://ex.org/type', 'http://ex.org/Dog'); - store.addTriple('http://ex.org/Mickey', 'http://ex.org/type', 'http://ex.org/Mouse'); + const store: N3.N3Store = new N3.Store(); + store.addQuad(N3.DataFactory.namedNode('http://ex.org/Pluto'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Dog')); + store.addQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))); + store.addQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]); + store.removeQuad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')); + store.removeQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))); + store.removeQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]); - var mickey = store.find('http://ex.org/Mickey', null, null)[0]; + const bnode1: RDF.BlankNode = store.createBlankNode(); + const bnode2: RDF.BlankNode = store.createBlankNode('abc'); + + const mickey: RDF.Quad = store.getQuads(N3.DataFactory.namedNode('http://ex.org/Mickey'), null, null, null)[0]; console.log(mickey.subject, mickey.predicate, mickey.object, '.'); } function test_doc_utility() { - var N3Util = N3.Util; - N3Util.isIRI('http://example.org/cartoons#Mickey'); // true + const N3Util = N3.Util; + N3Util.isNamedNode(N3.DataFactory.namedNode('http://example.org/cartoons#Mickey')); // true - N3Util.isLiteral('"Mickey Mouse"'); // true - N3Util.getLiteralValue('"Mickey Mouse"'); // 'Mickey Mouse' - N3Util.isLiteral('"Mickey Mouse"@en'); // true - N3Util.getLiteralLanguage('"Mickey Mouse"@en'); // 'en' - N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true - N3Util.getLiteralType('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // 'http://www.w3.org/2001/XMLSchema#integer' - N3Util.isLiteral('"http://example.org/"'); // true - N3Util.getLiteralValue('"http://example.org/"'); // 'http://example.org/' + N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse')); // true + N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse', 'en')); // true + N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true + N3Util.isLiteral(N3.DataFactory.literal('http://example.org/')); // true - N3Util.isLiteral('"This word is "quoted"!"'); // true - N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true + N3Util.isLiteral(N3.DataFactory.literal('This word is "quoted"!')); // true + N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true new N3.Parser().parse(' "This word is \\"quoted\\"!".', console.log); // { subject: 'a', predicate: 'b', object: '"This word is "quoted"!"' } - N3Util.createLiteral('My text', 'en-gb'); - N3Util.createLiteral('123', 'http://www.w3.org/2001/XMLSchema#integer'); - N3Util.createLiteral(123); - N3Util.createLiteral(false); + N3Util.isBlankNode(N3.DataFactory.blankNode('b1')); // true + N3Util.isNamedNode(N3.DataFactory.blankNode('b1')); // false + N3Util.isLiteral(N3.DataFactory.blankNode('b1')); // false - N3Util.isBlank('_:b1'); // true - N3Util.isIRI('_:b1'); // false - N3Util.isLiteral('_:b1'); // false - - var prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' }; - N3Util.isPrefixedName('rdfs:label'); // true; - N3Util.expandPrefixedName('rdfs:label', prefixes); // http://www.w3.org/2000/01/rdf-schema#label + const prefixes: N3.Prefixes = { rdfs: N3.DataFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#') }; + const namedNode1: RDF.NamedNode = N3Util.prefix('http://www.w3.org/2000/01/rdf-schema#')('label'); + const namedNode2: RDF.NamedNode = N3Util.prefixes(prefixes)('rdfs')('label'); } diff --git a/types/n3/tsconfig.json b/types/n3/tsconfig.json index 4ba121903d..11e61e58e3 100644 --- a/types/n3/tsconfig.json +++ b/types/n3/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "n3-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/n3/tslint.json b/types/n3/tslint.json index a41bf5d19a..d88586e5bd 100644 --- a/types/n3/tslint.json +++ b/types/n3/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 7745372a21..63b06965f6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -26,6 +26,7 @@ // Lishude // Andrew Makarov // Zane Hannan AU +// Thomas den Hollander // Eugene Y. Q. Shen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -172,6 +173,10 @@ interface SymbolConstructor { readonly asyncIterator: symbol; } declare var Symbol: SymbolConstructor; +interface SharedArrayBuffer { + readonly byteLength: number; + slice(begin?: number, end?: number): SharedArrayBuffer; +} // Node.js ESNEXT support interface String { @@ -349,13 +354,13 @@ declare var Buffer: { new(array: Uint8Array): Buffer; /** * Produces a Buffer backed by the same allocated memory as - * the given {ArrayBuffer}. + * the given {ArrayBuffer}/{SharedArrayBuffer}. * * * @param arrayBuffer The ArrayBuffer with which to share memory. * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead. */ - new(arrayBuffer: ArrayBuffer): Buffer; + new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer; /** * Allocates a new buffer containing the given {array} of octets. * @@ -379,8 +384,7 @@ declare var Buffer: { * * @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer() */ - from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer; - // from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; + from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer; /** * Creates a new Buffer using the passed {data} * @param data data to create a new Buffer @@ -418,7 +422,7 @@ declare var Buffer: { * @param string string to test. * @param encoding encoding used to evaluate (defaults to 'utf8') */ - byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number; + byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: string): number; /** * Returns a buffer which is the result of concatenating all the buffers in the list together. * @@ -2770,6 +2774,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2796,6 +2801,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index ce46e31654..a7fcd4d44a 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -446,6 +446,11 @@ function bufferTests() { const arrUint8: Uint8Array = new Uint8Array(2); const buf5: Buffer = Buffer.from(arrUint8); const buf6: Buffer = Buffer.from(buf1); + const sharedArrayBuffer: SharedArrayBuffer = { + byteLength: 10, + slice: (begin?: number, end?: number) => sharedArrayBuffer + }; + const buf7: Buffer = Buffer.from(sharedArrayBuffer); } // Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]]) @@ -3388,6 +3393,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** diff --git a/types/node/v8/index.d.ts b/types/node/v8/index.d.ts index d8a1cb431c..dc44245c59 100644 --- a/types/node/v8/index.d.ts +++ b/types/node/v8/index.d.ts @@ -2646,6 +2646,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2672,6 +2673,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/v8/node-tests.ts b/types/node/v8/node-tests.ts index 9cec14a88e..d89e6faacc 100644 --- a/types/node/v8/node-tests.ts +++ b/types/node/v8/node-tests.ts @@ -3127,6 +3127,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** diff --git a/types/node/v9/index.d.ts b/types/node/v9/index.d.ts index 8150a68294..fd89e18e16 100644 --- a/types/node/v9/index.d.ts +++ b/types/node/v9/index.d.ts @@ -2728,6 +2728,7 @@ declare module "dns" { export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; + export function getServers(): string[]; // Error codes export var NODATA: string; @@ -2754,6 +2755,25 @@ declare module "dns" { export var LOADIPHLPAPI: string; export var ADDRGETNETWORKPARAMS: string; export var CANCELLED: string; + + export class Resolver { + getServers: typeof getServers; + setServers: typeof setServers; + resolve: typeof resolve; + resolve4: typeof resolve4; + resolve6: typeof resolve6; + resolveAny: typeof resolveAny; + resolveCname: typeof resolveCname; + resolveMx: typeof resolveMx; + resolveNaptr: typeof resolveNaptr; + resolveNs: typeof resolveNs; + resolvePtr: typeof resolvePtr; + resolveSoa: typeof resolveSoa; + resolveSrv: typeof resolveSrv; + resolveTxt: typeof resolveTxt; + reverse: typeof reverse; + cancel(): void; + } } declare module "net" { diff --git a/types/node/v9/node-tests.ts b/types/node/v9/node-tests.ts index 3d7861f532..ace737fa3b 100644 --- a/types/node/v9/node-tests.ts +++ b/types/node/v9/node-tests.ts @@ -3160,6 +3160,14 @@ namespace dns_tests { const _addresses: string[] | dns.RecordWithTtl[] = addresses; }); } + { + const resolver = new dns.Resolver(); + resolver.setServers(["4.4.4.4"]); + resolver.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + resolver.cancel(); + } } /***************************************************************************** diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index f900beffe8..2f8a3ee7bc 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -600,6 +600,7 @@ declare namespace Office { } /** * Represents the runtime environment of the add-in and provides access to key objects of the API. + * The current context exists as a property of Office. It is accessed using `Office.context`. * * @remarks *
HostsAccess, Excel, Outlook, PowerPoint, Project, Word
@@ -1021,7 +1022,11 @@ declare namespace Office { */ closeContainer(): void; /** - * Opens a browser window and loads the specified URL. + * For internal Microsoft use only. Do not call from your code. Opens a browser window and loads the specified URL. + * + * @remarks + *
Requirement setsOpenBrowserWindowAPI 1.1
+ * * @param url The full URL to be opened including protocol (e.g., https), and port number, if any. */ openBrowserWindow(url: string): void; @@ -15961,25 +15966,24 @@ declare namespace Excel { */ function run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise; /** - * Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. - * - * @remarks - * - * In addition to this signature, the method also has the following signatures: - * - * `run(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * `run(batch: (context: Excel.RequestContext) => Promise): Promise;` - * - * @param context - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". - * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. - */ - function run(context: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise): Promise; - function createWorkbook(base64?: string): Promise; + * Executes a batch script that performs actions on the Excel object model, using the RequestContext of a previously-created object. When the promise is resolved, any tracked objects that were automatically allocated during execution will be released. + * + * @remarks + * + * In addition to this signature, the method also has the following signatures: + * + * `run(object: OfficeExtension.ClientObject, batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(objects: OfficeExtension.ClientObject[], batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(options: Excel.RunOptions, batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * `run(batch: (context: Excel.RequestContext) => Promise): Promise;` + * + * @param context - A previously-created object. The batch will use the same RequestContext as the passed-in object, which means that any changes applied to the object will be picked up by "context.sync()". + * @param batch - A function that takes in a RequestContext and returns a promise (typically, just the result of "context.sync()"). The context parameter facilitates requests to the Excel application. Since the Office add-in and the Excel application run in two different processes, the RequestContext is required to get access to the Excel object model from the add-in. + */ + function run(context: OfficeExtension.ClientRequestContext, batch: (context: Excel.RequestContext) => Promise): Promise; /** * * Provides information about the binding that raised the SelectionChanged event. @@ -16578,7 +16582,7 @@ declare namespace Excel { getActiveCell(): Excel.Range; /** * - * Gets the currently selected range from the workbook. + * Gets the currently selected single range from the workbook. If there are multiple ranges selected, this method will throw an error. * * [Api set: ExcelApi 1.1] */ @@ -16876,11 +16880,11 @@ declare namespace Excel { getPreviousOrNullObject(visibleOnly?: boolean): Excel.Worksheet; /** * - * Gets the range object specified by the address or name. + * Gets the range object, representing a single rectangular block of cells, specified by the address or name. * * [Api set: ExcelApi 1.1] * - * @param address Optional. The address or the name of the range. If not specified, the entire worksheet range is returned. + * @param address Optional. The string representing the address or name of the range. For example, "A1:B2". If not specified, the entire worksheet range is returned. */ getRange(address?: string): Excel.Range; /** @@ -17364,7 +17368,7 @@ declare namespace Excel { readonly worksheet: Excel.Worksheet; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -17593,7 +17597,7 @@ declare namespace Excel { getAbsoluteResizedRange(numRows: number, numColumns: number): Excel.Range; /** * - * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E16". + * Gets the smallest range object that encompasses the given ranges. For example, the GetBoundingRect of "B2:C5" and "D10:E15" is "B2:E15". * * [Api set: ExcelApi 1.1] * @@ -17806,7 +17810,6 @@ declare namespace Excel { /** * * Selects the specified range in the Excel UI. - If true, a multi-area range can be selected; otherwise, only the first area will be selected. Default is false. * * [Api set: ExcelApi 1.1] */ @@ -19217,10 +19220,10 @@ declare namespace Excel { * * Represents a collection of all the rows that are part of the table. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -19238,10 +19241,10 @@ declare namespace Excel { * * Adds one or more rows to the table. The return object will be the top of the newly added row(s). - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1 for adding a single row; 1.4 allows adding of multiple rows.] * @@ -19260,10 +19263,10 @@ declare namespace Excel { * * Gets a row based on its position in the collection. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] * @@ -19294,10 +19297,10 @@ declare namespace Excel { * * Represents a row in a table. - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -19891,7 +19894,7 @@ declare namespace Excel { * @param sourceData The Range object corresponding to the source data. * @param seriesBy Optional. Specifies the way columns or rows are used as data series on the chart. See Excel.ChartSeriesBy for details. */ - add(type: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap", sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): Excel.Chart; + add(type: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel", sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): Excel.Chart; /** * * Returns the number of charts in the worksheet. @@ -20009,7 +20012,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -20110,7 +20113,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.1] * - * @param sourceData The range corresponding to the source data. + * @param sourceData The range object corresponding to the source data. * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, and Columns. See Excel.ChartSeriesBy for details. */ setData(sourceData: Range, seriesBy?: Excel.ChartSeriesBy): void; @@ -20120,7 +20123,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.1] * - * @param sourceData The range corresponding to the source data. + * @param sourceData The range object corresponding to the source data. * @param seriesBy Specifies the way columns or rows are used as data series on the chart. Can be one of the following: Auto (default), Rows, and Columns. See Excel.ChartSeriesBy for details. */ setData(sourceData: Range, seriesBy?: "Auto" | "Columns" | "Rows"): void; @@ -20318,7 +20321,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -23976,14 +23979,14 @@ declare namespace Excel { delete(): void; /** * - * Returns the range the conditonal format is applied to. Read-only. + * Returns the range the conditonal format is applied to. Throws an error if the conditional format is applied to multiple ranges. Read-only. * * [Api set: ExcelApi 1.6] */ getRange(): Excel.Range; /** * - * Returns the range the conditonal format is applied to or a null object if the range is discontiguous. Read-only. + * Returns the range the conditonal format is applied to, or a null object if the conditional format is applied to multiple ranges. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -26665,7 +26668,7 @@ declare namespace Excel { worksheetCalculated = "WorksheetCalculated", /** * - * ChartActivated represents the type of event registered on Chart or ChartCollection, and occurs when chart activates. + * VisualSelectionChanged represents the type of event registered on VisualCollection, and occurs when visual selection changes. * */ visualSelectionChanged = "VisualSelectionChanged", @@ -31246,7 +31249,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -31326,7 +31329,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -33264,7 +33267,7 @@ declare namespace Excel { worksheet?: Excel.Interfaces.WorksheetData; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -34083,7 +34086,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the height, in points, of the chart object. @@ -34184,7 +34187,7 @@ declare namespace Excel { * * [Api set: ExcelApi 1.7] */ - chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap"; + chartType?: Excel.ChartType | "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"; /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. @@ -36395,7 +36398,7 @@ declare namespace Excel { worksheet?: Excel.Interfaces.WorksheetLoadOptions; /** * - * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. Sheet1!A1:B4). Read-only. + * Represents the range reference in A1-style. Address value will contain the Sheet reference (e.g. "Sheet1!A1:B4"). Read-only. * * [Api set: ExcelApi 1.1] */ @@ -36438,7 +36441,7 @@ declare namespace Excel { /** * * Represents the formula in A1-style notation. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36446,7 +36449,7 @@ declare namespace Excel { /** * * Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36454,7 +36457,7 @@ declare namespace Excel { /** * * Represents the formula in R1C1-style notation. - When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting formulas to a range, the value argument can be either a single value (a string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.2] */ @@ -36490,7 +36493,7 @@ declare namespace Excel { /** * * Represents Excel's number format code for the given range. - When setting number format to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting number format to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -36498,7 +36501,7 @@ declare namespace Excel { /** * * Represents Excel's number format code for the given range as a string in the language of the user. - When setting number format local to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting number format local to a range, the value argument can be either a single value (string) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.7] */ @@ -36527,8 +36530,8 @@ declare namespace Excel { /** * * Represents the style of the current range. - If the styles of the cells are inconsistent, null will be returned. - For custom styles, the style name will be returned. For built-in styles, a string representing a value in the BuiltInStyle enum will be returned. + If the styles of the cells are inconsistent, null will be returned. + For custom styles, the style name will be returned. For built-in styles, a string representing a value in the BuiltInStyle enum will be returned. * * [Api set: ExcelApi 1.7] */ @@ -36550,7 +36553,7 @@ declare namespace Excel { /** * * Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cells that contain an error will return the error string. - When setting values to a range, the value argument can be either a single value (string, number or boolean) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. + When setting values to a range, the value argument can be either a single value (string, number or boolean) or a two-dimensional array. If the argument is a single value, it will be applied to all cells in the range. * * [Api set: ExcelApi 1.1] */ @@ -37306,11 +37309,11 @@ declare namespace Excel { /** * * Represents a collection of all the rows that are part of the table. - - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -37334,11 +37337,11 @@ declare namespace Excel { /** * * Represents a row in a table. - - Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, - a TableRow object represent the physical location of the table row, but not the data. - That is, if the data is sorted or if new rows are added, a table row will continue - to point at the index for which it was created. + + Note that unlike Ranges or Columns, which will adjust if new rows/columns are added before them, + a TableRow object represent the physical location of the table row, but not the data. + That is, if the data is sorted or if new rows are added, a table row will continue + to point at the index for which it was created. * * [Api set: ExcelApi 1.1] */ @@ -37419,8 +37422,8 @@ declare namespace Excel { /** * * Gets or sets the text orientation of all the cells within the range. - The text orientation should be an integer either from -90 to 90, or 180 for vertically-oriented text. - If the orientation within a range are not uniform, then null will be returned. + The text orientation should be an integer either from -90 to 90, or 180 for vertically-oriented text. + If the orientation within a range are not uniform, then null will be returned. * * [Api set: ExcelApi 1.7] */ @@ -37428,9 +37431,9 @@ declare namespace Excel { /** * * Determines if the row height of the Range object equals the standard height of the sheet. - Returns True if the row height of the Range object equals the standard height of the sheet. - Returns Null if the range contains more than one row and the rows aren't all the same height. - Returns False otherwise. + Returns True if the row height of the Range object equals the standard height of the sheet. + Returns Null if the range contains more than one row and the rows aren't all the same height. + Returns False otherwise. * * [Api set: ExcelApi 1.7] */ @@ -37438,9 +37441,9 @@ declare namespace Excel { /** * * Indicates whether the column width of the Range object equals the standard width of the sheet. - Returns True if the column width of the Range object equals the standard width of the sheet. - Returns Null if the range contains more than one column and the columns aren't all the same height. - Returns False otherwise. + Returns True if the column width of the Range object equals the standard width of the sheet. + Returns Null if the range contains more than one column and the columns aren't all the same height. + Returns False otherwise. * * [Api set: ExcelApi 1.7] */ @@ -37907,7 +37910,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. - Throws an invalid argument exception on invalid charts. + Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -37922,7 +37925,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Represents the gap width of a chart series. Only valid on bar and column charts, as well as - specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. + specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -38023,7 +38026,7 @@ declare namespace Excel { /** * * Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. - Throws an invalid argument exception on invalid charts. + Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -38038,7 +38041,7 @@ declare namespace Excel { /** * * Represents the gap width of a chart series. Only valid on bar and column charts, as well as - specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. + specific classes of line and pie charts. Throws an invalid argument exception on invalid charts. * * [Api set: ExcelApi 1.7] */ @@ -39330,8 +39333,8 @@ declare namespace Excel { /** * * A scoped collection of custom XML parts. - A scoped collection is the result of some operation, e.g. filtering by namespace. - A scoped collection cannot be scoped any further. + A scoped collection is the result of some operation, e.g. filtering by namespace. + A scoped collection cannot be scoped any further. * * [Api set: ExcelApi 1.5] */ @@ -39615,7 +39618,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39623,7 +39626,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39701,7 +39704,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39709,7 +39712,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39717,7 +39720,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39725,7 +39728,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39740,10 +39743,10 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: The priority (or index) within the conditional format collection that this conditional format currently exists in. Changing this also - changes other conditional formats' priorities, to allow for a contiguous priority order. - Use a negative priority to begin from the back. - Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. - Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. + changes other conditional formats' priorities, to allow for a contiguous priority order. + Use a negative priority to begin from the back. + Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. + Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -39751,7 +39754,7 @@ declare namespace Excel { /** * * For EACH ITEM in the collection: If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. - Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these + Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these * * [Api set: ExcelApi 1.6] */ @@ -39775,7 +39778,7 @@ declare namespace Excel { /** * * Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39783,7 +39786,7 @@ declare namespace Excel { /** * * Returns the cell value conditional format properties if the current conditional format is a CellValue type. - For example to format all cells between 5 and 10. + For example to format all cells between 5 and 10. * * [Api set: ExcelApi 1.6] */ @@ -39861,7 +39864,7 @@ declare namespace Excel { /** * * Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39869,7 +39872,7 @@ declare namespace Excel { /** * * Returns the specific text conditional format properties if the current conditional format is a text type. - For example to format cells matching the word "Text". + For example to format cells matching the word "Text". * * [Api set: ExcelApi 1.6] */ @@ -39877,7 +39880,7 @@ declare namespace Excel { /** * * Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39885,7 +39888,7 @@ declare namespace Excel { /** * * Returns the Top/Bottom conditional format properties if the current conditional format is an TopBottom type. - For example to format the top 10% or bottom 10 items. + For example to format the top 10% or bottom 10 items. * * [Api set: ExcelApi 1.6] */ @@ -39900,10 +39903,10 @@ declare namespace Excel { /** * * The priority (or index) within the conditional format collection that this conditional format currently exists in. Changing this also - changes other conditional formats' priorities, to allow for a contiguous priority order. - Use a negative priority to begin from the back. - Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. - Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. + changes other conditional formats' priorities, to allow for a contiguous priority order. + Use a negative priority to begin from the back. + Priorities greater than than bounds will get and set to the maximum (or minimum if negative) priority. + Also note that if you change the priority, you have to re-fetch a new copy of the object at that new priority location if you want to make further changes to it. Read-only. * * [Api set: ExcelApi 1.6] */ @@ -39911,7 +39914,7 @@ declare namespace Excel { /** * * If the conditions of this conditional format are met, no lower-priority formats shall take effect on that cell. - Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these + Null on databars, icon sets, and colorscales as there's no concept of StopIfTrue for these * * [Api set: ExcelApi 1.6] */ @@ -39949,7 +39952,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the Axis line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "" (empty string) if no axis is present or set. + "" (empty string) if no axis is present or set. * * [Api set: ExcelApi 1.6] */ @@ -40001,7 +40004,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "" (empty string) if no border is present or set. + "" (empty string) if no border is present or set. * * [Api set: ExcelApi 1.6] */ @@ -40032,7 +40035,7 @@ declare namespace Excel { /** * * HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange"). - "Empty String" if no border is present or set. + "Empty String" if no border is present or set. * * [Api set: ExcelApi 1.6] */ @@ -40920,10 +40923,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly type: Word.BodyType | "Unknown" | "MainDoc" | "Section" | "Header" | "Footer" | "TableCell"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Body): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.BodyUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Body): void; + set(properties: Word.Body): void; /** * * Clears the contents of the body object. The user can perform the undo operation on the cleared content. @@ -41140,7 +41153,7 @@ declare namespace Word { * * [Api set: WordApi 1.1] * - * @param searchText Required. The search text. + * @param searchText Required. The search text. Can be a maximum of 255 characters. * @param searchOptions Optional. Options for the search. */ search(searchText: string, searchOptions?: Word.SearchOptions | { @@ -41172,6 +41185,18 @@ declare namespace Word { select(selectionMode?: "Select" | "Start" | "End"): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Body` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Body` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Body` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.BodyLoadOptions): Word.Body; load(option?: string | string[]): Word.Body; @@ -41385,10 +41410,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly type: Word.ContentControlType | "Unknown" | "RichTextInline" | "RichTextParagraphs" | "RichTextTableCell" | "RichTextTableRow" | "RichTextTable" | "PlainTextInline" | "PlainTextParagraph" | "Picture" | "BuildingBlockGallery" | "CheckBox" | "ComboBox" | "DropDownList" | "DatePicker" | "RepeatingSection" | "RichText" | "PlainText"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.ContentControl): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ContentControlUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: ContentControl): void; + set(properties: Word.ContentControl): void; /** * * Clears the contents of the content control. The user can perform the undo operation on the cleared content. @@ -41661,6 +41696,18 @@ declare namespace Word { split(delimiters: string[], multiParagraphs?: boolean, trimDelimiters?: boolean, trimSpacing?: boolean): Word.RangeCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ContentControl` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ContentControl` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ContentControl` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ContentControlLoadOptions): Word.ContentControl; load(option?: string | string[]): Word.ContentControl; @@ -41757,6 +41804,18 @@ declare namespace Word { getItem(index: number): Word.ContentControl; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ContentControlCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ContentControlCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ContentControlCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ContentControlCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ContentControlCollection; load(option?: string | string[]): Word.ContentControlCollection; @@ -41799,10 +41858,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ value: any; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.CustomProperty): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.CustomPropertyUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: CustomProperty): void; + set(properties: Word.CustomProperty): void; /** * * Deletes the custom property. @@ -41812,6 +41881,18 @@ declare namespace Word { delete(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.CustomProperty` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.CustomProperty` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.CustomProperty` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.CustomPropertyLoadOptions): Word.CustomProperty; load(option?: string | string[]): Word.CustomProperty; @@ -41882,6 +41963,18 @@ declare namespace Word { getItemOrNullObject(key: string): Word.CustomProperty; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.CustomPropertyCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.CustomPropertyCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.CustomPropertyCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.CustomPropertyCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.CustomPropertyCollection; load(option?: string | string[]): Word.CustomPropertyCollection; @@ -41938,10 +42031,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly saved: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Document): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Document): void; + set(properties: Word.Document): void; /** * * Gets the current selection of the document. Multiple selections are not supported. @@ -41958,6 +42061,18 @@ declare namespace Word { save(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Document` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Document` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Document` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentLoadOptions): Word.Document; load(option?: string | string[]): Word.Document; @@ -42017,10 +42132,20 @@ declare namespace Word { * [Api set: WordApiHiddenDocument 1.3] */ readonly saved: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.DocumentCreated): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentCreatedUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: DocumentCreated): void; + set(properties: Word.DocumentCreated): void; /** * * Opens the document. @@ -42037,6 +42162,18 @@ declare namespace Word { save(): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.DocumentCreated` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.DocumentCreated` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.DocumentCreated` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentCreatedLoadOptions): Word.DocumentCreated; load(option?: string | string[]): Word.DocumentCreated; @@ -42187,12 +42324,34 @@ declare namespace Word { * [Api set: WordApi 1.3] */ title: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.DocumentProperties): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.DocumentPropertiesUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: DocumentProperties): void; + set(properties: Word.DocumentProperties): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.DocumentProperties` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.DocumentProperties` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.DocumentProperties` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.DocumentPropertiesLoadOptions): Word.DocumentProperties; load(option?: string | string[]): Word.DocumentProperties; @@ -42294,12 +42453,34 @@ declare namespace Word { * [Api set: WordApi 1.1] */ underline: Word.UnderlineType | "Mixed" | "None" | "Hidden" | "DotLine" | "Single" | "Word" | "Double" | "Thick" | "Dotted" | "DottedHeavy" | "DashLine" | "DashLineHeavy" | "DashLineLong" | "DashLineLongHeavy" | "DotDashLine" | "DotDashLineHeavy" | "TwoDotDashLine" | "TwoDotDashLineHeavy" | "Wave" | "WaveHeavy" | "WaveDouble"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Font): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.FontUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Font): void; + set(properties: Word.Font): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Font` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Font` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Font` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.FontLoadOptions): Word.Font; load(option?: string | string[]): Word.Font; @@ -42415,10 +42596,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.InlinePicture): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.InlinePictureUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: InlinePicture): void; + set(properties: Word.InlinePicture): void; /** * * Deletes the inline picture from the document. @@ -42632,6 +42823,18 @@ declare namespace Word { select(selectionMode?: "Select" | "Start" | "End"): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.InlinePicture` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.InlinePicture` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.InlinePicture` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.InlinePictureLoadOptions): Word.InlinePicture; load(option?: string | string[]): Word.InlinePicture; @@ -42674,6 +42877,18 @@ declare namespace Word { getFirstOrNullObject(): Word.InlinePicture; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.InlinePictureCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.InlinePictureCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.InlinePictureCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.InlinePictureCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.InlinePictureCollection; load(option?: string | string[]): Word.InlinePictureCollection; @@ -42850,6 +43065,18 @@ declare namespace Word { setLevelStartingNumber(level: number, startingNumber: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.List` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.List` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.List` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListLoadOptions): Word.List; load(option?: string | string[]): Word.List; @@ -42919,6 +43146,18 @@ declare namespace Word { getItem(index: number): Word.List; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ListCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ListCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ListCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ListCollection; load(option?: string | string[]): Word.ListCollection; @@ -42961,10 +43200,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly siblingIndex: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.ListItem): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ListItemUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: ListItem): void; + set(properties: Word.ListItem): void; /** * * Gets the list item parent, or the closest ancestor if the parent does not exist. Throws if the list item has no ancestor. @@ -42994,6 +43243,18 @@ declare namespace Word { getDescendants(directChildrenOnly?: boolean): Word.ParagraphCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ListItem` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ListItem` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ListItem` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ListItemLoadOptions): Word.ListItem; load(option?: string | string[]): Word.ListItem; @@ -43228,10 +43489,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly text: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Paragraph): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.ParagraphUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Paragraph): void; + set(properties: Word.Paragraph): void; /** * * Lets the paragraph join an existing list at the specified level. Fails if the paragraph cannot join the list or if the paragraph is already a list item. @@ -43560,6 +43831,18 @@ declare namespace Word { startNewList(): Word.List; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Paragraph` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Paragraph` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Paragraph` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ParagraphLoadOptions): Word.Paragraph; load(option?: string | string[]): Word.Paragraph; @@ -43616,6 +43899,18 @@ declare namespace Word { getLastOrNullObject(): Word.Paragraph; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.ParagraphCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.ParagraphCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.ParagraphCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.ParagraphCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.ParagraphCollection; load(option?: string | string[]): Word.ParagraphCollection; @@ -43763,10 +44058,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly text: string; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Range): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.RangeUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Range): void; + set(properties: Word.Range): void; /** * * Clears the contents of the range object. The user can perform the undo operation on the cleared content. @@ -44116,6 +44421,18 @@ declare namespace Word { split(delimiters: string[], multiParagraphs?: boolean, trimDelimiters?: boolean, trimSpacing?: boolean): Word.RangeCollection; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Range` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Range` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Range` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.RangeLoadOptions): Word.Range; load(option?: string | string[]): Word.Range; @@ -44158,6 +44475,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Range; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.RangeCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.RangeCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.RangeCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.RangeCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.RangeCollection; load(option?: string | string[]): Word.RangeCollection; @@ -44229,12 +44558,34 @@ declare namespace Word { * [Api set: WordApi 1.1] */ matchWildcards: boolean; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.SearchOptions): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.SearchOptionsUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: SearchOptions): void; + set(properties: Word.SearchOptions): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.SearchOptions` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.SearchOptions` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.SearchOptions` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SearchOptionsLoadOptions): Word.SearchOptions; load(option?: string | string[]): Word.SearchOptions; @@ -44262,10 +44613,20 @@ declare namespace Word { * [Api set: WordApi 1.1] */ readonly body: Word.Body; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Section): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.SectionUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Section): void; + set(properties: Word.Section): void; /** * * Gets one of the section's footers. @@ -44318,6 +44679,18 @@ declare namespace Word { getNextOrNullObject(): Word.Section; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Section` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Section` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Section` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SectionLoadOptions): Word.Section; load(option?: string | string[]): Word.Section; @@ -44360,6 +44733,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Section; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.SectionCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.SectionCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.SectionCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.SectionCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.SectionCollection; load(option?: string | string[]): Word.SectionCollection; @@ -44570,10 +44955,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.Table): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: Table): void; + set(properties: Word.Table): void; /** * * Adds columns to the start or end of the table, using the first or last existing column as a template. This is applicable to uniform tables. The string values, if specified, are set in the newly inserted rows. @@ -44891,6 +45286,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.Table` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.Table` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.Table` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableLoadOptions): Word.Table; load(option?: string | string[]): Word.Table; @@ -44933,6 +45340,18 @@ declare namespace Word { getFirstOrNullObject(): Word.Table; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableCollection; load(option?: string | string[]): Word.TableCollection; @@ -45031,10 +45450,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ verticalAlignment: Word.VerticalAlignment | "Mixed" | "Top" | "Center" | "Bottom"; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableRow): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableRowUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableRow): void; + set(properties: Word.TableRow): void; /** * * Clears the contents of the row. @@ -45179,6 +45608,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableRow` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableRow` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableRow` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableRowLoadOptions): Word.TableRow; load(option?: string | string[]): Word.TableRow; @@ -45221,6 +45662,18 @@ declare namespace Word { getFirstOrNullObject(): Word.TableRow; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableRowCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableRowCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableRowCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableRowCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableRowCollection; load(option?: string | string[]): Word.TableRowCollection; @@ -45319,10 +45772,20 @@ declare namespace Word { * [Api set: WordApi 1.3] */ readonly width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableCell): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableCellUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableCell): void; + set(properties: Word.TableCell): void; /** * * Deletes the column containing this cell. This is applicable to uniform tables. @@ -45453,6 +45916,18 @@ declare namespace Word { setCellPadding(cellPaddingLocation: "Top" | "Left" | "Bottom" | "Right", cellPadding: number): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCell` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCell` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCell` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCellLoadOptions): Word.TableCell; load(option?: string | string[]): Word.TableCell; @@ -45495,6 +45970,18 @@ declare namespace Word { getFirstOrNullObject(): Word.TableCell; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableCellCollection` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableCellCollection` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableCellCollection` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableCellCollectionLoadOptions & Word.Interfaces.CollectionLoadOptions): Word.TableCellCollection; load(option?: string | string[]): Word.TableCellCollection; @@ -45537,12 +46024,34 @@ declare namespace Word { * [Api set: WordApi 1.3] */ width: number; - /** Sets multiple properties on the object at the same time, based on JSON input. */ + /** Sets multiple properties of an object at the same time. You can pass either a plain object with the appropriate properties, or another API object of the same type. + * + * @remarks + * + * This method has the following additional signature: + * + * `set(properties: Word.TableBorder): void` + * + * @param properties A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called. + * @param options Provides an option to suppress errors if the properties object tries to set any read-only properties. + */ set(properties: Interfaces.TableBorderUpdateData, options?: OfficeExtension.UpdateOptions): void; /** Sets multiple properties on the object at the same time, based on an existing loaded object. */ - set(properties: TableBorder): void; + set(properties: Word.TableBorder): void; /** * Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties. + * + * @remarks + * + * In addition to this signature, this method has the following signatures: + * + * `load(option?: string | string[]): Word.TableBorder` - Where option is a comma-delimited string or an array of strings that specify the properties/relationships to load. + * + * `load(option?: { select?: string; expand?: string; }): Word.TableBorder` - Where option.select is a comma-delimited string that specifies the properties/relationships to load, and options.expand is a comma-delimited string that specifies the relationships to load. + * + * `load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Word.TableBorder` - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items. + * + * @param options Provides options for which properties of the object to load. */ load(option?: Word.Interfaces.TableBorderLoadOptions): Word.TableBorder; load(option?: string | string[]): Word.TableBorder; @@ -46374,8 +46883,17 @@ declare namespace Word { notImplemented = "NotImplemented", } module Interfaces { + /** + * Provides ways to load properties of only a subset of members of a collection. + */ interface CollectionLoadOptions { + /** + * Specify the number of items in the queried collection to be included in the result. + */ $top?: number; + /** + * Specify the number of items in the collection that are to be skipped and not included in the result. If top is specified, the selection of result will start after skipping the specified number of items. + */ $skip?: number; } /** An interface for updating data on the Body object, for use in "body.set({ ... })". */ @@ -54564,15 +55082,6 @@ declare namespace OneNote { */ numberType: OneNote.NumberType | "None" | "Arabic" | "UCRoman" | "LCRoman" | "UCLetter" | "LCLetter" | "Ordinal" | "Cardtext" | "Ordtext" | "Hex" | "ChiManSty" | "DbNum1" | "DbNum2" | "Aiueo" | "Iroha" | "DbChar" | "SbChar" | "DbNum3" | "DbNum4" | "Circlenum" | "DArabic" | "DAiueo" | "DIroha" | "ArabicLZ" | "Bullet" | "Ganada" | "Chosung" | "GB1" | "GB2" | "GB3" | "GB4" | "Zodiac1" | "Zodiac2" | "Zodiac3" | "TpeDbNum1" | "TpeDbNum2" | "TpeDbNum3" | "TpeDbNum4" | "ChnDbNum1" | "ChnDbNum2" | "ChnDbNum3" | "ChnDbNum4" | "KorDbNum1" | "KorDbNum2" | "KorDbNum3" | "KorDbNum4" | "Hebrew1" | "Arabic1" | "Hebrew2" | "Arabic2" | "Hindi1" | "Hindi2" | "Hindi3" | "Thai1" | "Thai2" | "NumInDash" | "LCRus" | "UCRus" | "LCGreek" | "UCGreek" | "Lim" | "Custom"; } - /** - * [Api set: OneNoteApi 1.1] - */ - enum EntityType { - notebook = "Notebook", - sectionGroup = "SectionGroup", - section = "Section", - page = "Page", - } /** * [Api set: OneNoteApi 1.1] */ @@ -55834,6 +56343,7 @@ declare namespace OneNote { interface TableCellCollectionData { items?: OneNote.Interfaces.TableCellData[]; } + /** * * Represents the top-level object that contains all globally addressable OneNote objects such as notebooks, the active notebook, and the active section. @@ -57505,182 +58015,6 @@ declare namespace OneNote { */ shadingColor?: boolean; } - /** - * - * Represents a OneNote accessibility violation. - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationLoadOptions { - $all?: boolean; - /** - * - * Gets the ID of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * Gets the location of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - location?: boolean; - /** - * - * Gets the name of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - name?: boolean; - /** - * - * Gets the type of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - type?: boolean; - } - /** - * - * Represents the collection of AccessibilityViolations - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationCollectionLoadOptions { - $all?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the ID of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the location of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - location?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the name of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - name?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the type of the accessibility violation. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - type?: boolean; - } - /** - * - * A OneNote structure that stores metadata about accessibility violations for an entity. - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationsByEntityLoadOptions { - $all?: boolean; - /** - * - * Gets the parent section section group (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionGroupOrNull?: OneNote.Interfaces.SectionGroupLoadOptions; - /** - * - * Gets the parent section (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionOrNull?: OneNote.Interfaces.SectionLoadOptions; - /** - * - * Gets the name of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityName?: boolean; - /** - * - * Gets the type of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityType?: boolean; - /** - * - * Gets the ID of the AccessibilityViolationsByEntity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * Gets the count of accessibility violations for the entity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - violationsCount?: boolean; - } - /** - * - * Represents the collection of AccessibilityViolationsByEntity - * - * [Api set: OneNoteApi 1.2] - */ - interface AccessibilityViolationsByEntityCollectionLoadOptions { - $all?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the parent section section group (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionGroupOrNull?: OneNote.Interfaces.SectionGroupLoadOptions; - /** - * - * For EACH ITEM in the collection: Gets the parent section (if any) of the entity. - * - * [Api set: OneNoteApi 1.2] - */ - parentSectionOrNull?: OneNote.Interfaces.SectionLoadOptions; - /** - * - * For EACH ITEM in the collection: Gets the name of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityName?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the type of the entity for which this structure holds metadata. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - entityType?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the ID of the AccessibilityViolationsByEntity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - id?: boolean; - /** - * - * For EACH ITEM in the collection: Gets the count of accessibility violations for the entity. Read-only. - * - * [Api set: OneNoteApi 1.2] - */ - violationsCount?: boolean; - } } } declare namespace OneNote { @@ -60300,4 +60634,4 @@ declare namespace Visio { //////////////////////////////////////////////////////////////// ////////////////////// End PowerPoint APIs ///////////////////// -//////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/types/p-retry/index.d.ts b/types/p-retry/index.d.ts index 784f637549..c1791fcc63 100644 --- a/types/p-retry/index.d.ts +++ b/types/p-retry/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for p-retry 1.0 +// Type definitions for p-retry 2.0 // Project: https://github.com/sindresorhus/p-retry#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,7 +8,7 @@ import { OperationOptions } from 'retry'; export = pRetry; -declare function pRetry(input: (attemptCount: number) => PromiseLike | T, options?: OperationOptions): Promise; +declare function pRetry(input: (attemptCount: number) => PromiseLike | T, options?: pRetry.Options): Promise; declare namespace pRetry { class AbortError extends Error { @@ -16,4 +16,13 @@ declare namespace pRetry { readonly originalError: Error; constructor(message: string | Error); } + + interface FailedAttemptError extends Error { + attemptNumber: number; + attemptsLeft: number; + } + + interface Options extends OperationOptions { + onFailedAttempt?: (error: FailedAttemptError) => void; + } } diff --git a/types/p-retry/p-retry-tests.ts b/types/p-retry/p-retry-tests.ts index 72962d553e..1b58960e95 100644 --- a/types/p-retry/p-retry-tests.ts +++ b/types/p-retry/p-retry-tests.ts @@ -11,6 +11,11 @@ const run = () => fetch('https://sindresorhus.com/unicorn') return response.text(); }); -pRetry(run, {retries: 5}).then(result => { +pRetry(run, { + retries: 5, + onFailedAttempt: error => { + console.log(`Attempt ${error.attemptNumber} failed. There are ${error.attemptsLeft} attempts left.`); + } +}).then(result => { const str: string = result; }); diff --git a/types/passport-strategy/index.d.ts b/types/passport-strategy/index.d.ts index 1a0b2dd4f5..33b35ddbaf 100644 --- a/types/passport-strategy/index.d.ts +++ b/types/passport-strategy/index.d.ts @@ -45,7 +45,7 @@ declare class Strategy implements passport.Strategy { * @param {Object} info * @api public */ - success(user: any, info: any): void; + success(user: any, info?: any): void; /** * Fail authentication, with optional `challenge` and `status`, defaulting diff --git a/types/passport-strategy/passport-strategy-tests.ts b/types/passport-strategy/passport-strategy-tests.ts index e9c6fd604f..4b8090d241 100644 --- a/types/passport-strategy/passport-strategy-tests.ts +++ b/types/passport-strategy/passport-strategy-tests.ts @@ -33,7 +33,7 @@ export class Strategy extends passport.Strategy { var self = this; - function verified(err: Error, user: any, info: any) { + function verified(err: Error, user: any, info?: any) { if (err) { return self.error(err); } @@ -43,6 +43,6 @@ export class Strategy extends passport.Strategy { self.success(user, info); } - verified(null, {}, {}); + verified(null, {}); } } diff --git a/types/puppeteer/puppeteer-tests.ts b/types/puppeteer/puppeteer-tests.ts index 96cb4fd361..e883157fec 100644 --- a/types/puppeteer/puppeteer-tests.ts +++ b/types/puppeteer/puppeteer-tests.ts @@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer"; // Get the "viewport" of the page, as reported by the page. const dimensions = await page.evaluate(() => { return { - width: document.documentElement.clientWidth, - height: document.documentElement.clientHeight, + width: document.documentElement!.clientWidth, + height: document.documentElement!.clientHeight, deviceScaleFactor: window.devicePixelRatio }; }); @@ -300,7 +300,7 @@ puppeteer.launch().then(async browser => { someElement; // $ExpectType ElementHandle // If one passes an ElementHandle, puppeteer will unwrap its DOM reference instead - await page.$eval('.hello-world', (e, x1: HTMLDivElement) => x1.noWrap, someElement); + await page.$eval('.hello-world', (e, x1) => (x1 as any).noWrap, someElement); browser.close(); })(); diff --git a/types/react-native-datepicker/index.d.ts b/types/react-native-datepicker/index.d.ts index 929acdc375..365fb6ced6 100644 --- a/types/react-native-datepicker/index.d.ts +++ b/types/react-native-datepicker/index.d.ts @@ -6,11 +6,12 @@ import * as React from 'react'; import { ImageURISource } from 'react-native'; +import * as moment from 'moment'; export interface DatePickerProps { mode?: 'date' | 'datetime' | 'time'; androidMode?: 'default' | 'calendar' | 'spinner'; - date?: string | Date; + date?: string | Date | moment.Moment; format?: string; iconSource?: ImageURISource; iconComponent?: JSX.Element; diff --git a/types/react-native-datepicker/package.json b/types/react-native-datepicker/package.json new file mode 100644 index 0000000000..19e5fb0d14 --- /dev/null +++ b/types/react-native-datepicker/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.14.0" + } +} diff --git a/types/react-native-vector-icons/FontAwesome5.d.ts b/types/react-native-vector-icons/FontAwesome5.d.ts new file mode 100644 index 0000000000..79c77ff0e2 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5.d.ts @@ -0,0 +1,43 @@ +import { Component } from "react"; +import { Icon, IconProps, ImageSource } from "./Icon"; + +export const FA5Style: { + regular: 0; + light: 1; + solid: 2; + brand: 3; +}; + +export type ValueOf = T[keyof T]; + +// borrowed from +// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html +export type Omit = Pick>; + +export type FontAwesome5IconVariants = keyof Omit; + +// modified from https://stackoverflow.com/a/49725198/1105281 +export type AllowOnlyOne = Omit & + { + [K in Keys]-?: Partial> & + Partial, undefined>> + }[Keys]; + +export type FontAwesome5IconProps = AllowOnlyOne< + { [K in FontAwesome5IconVariants]?: boolean } & IconProps, + FontAwesome5IconVariants +>; + +export default class FontAwesome5Icon extends Component< + FontAwesome5IconProps, + any +> { + static getImageSource( + name: string, + size?: number, + color?: string, + fa5Style?: ValueOf + ): Promise; + static loadFont(file?: string): Promise; + static hasIcon(name: string): boolean; +} diff --git a/types/react-native-vector-icons/FontAwesome5Pro.d.ts b/types/react-native-vector-icons/FontAwesome5Pro.d.ts new file mode 100644 index 0000000000..f8233abce5 --- /dev/null +++ b/types/react-native-vector-icons/FontAwesome5Pro.d.ts @@ -0,0 +1,6 @@ +import { Component } from "react"; +import FontAwesome5Icon, { FontAwesome5IconProps } from "./FontAwesome5"; + +export type FontAwesome5ProIconProps = FontAwesome5IconProps; +export { FA5Style } from "./FontAwesome5"; +export default FontAwesome5Icon; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 51cb1eee81..18b03edcaa 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -3,6 +3,8 @@ import { View, Text, TabBarIOS } from 'react-native'; import { createIconSet } from 'react-native-vector-icons'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; +import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5'; +import FontAwesome5ProIcon from 'react-native-vector-icons/FontAwesome5Pro'; import Ionicon from 'react-native-vector-icons/Ionicons'; const glyphMap = { @@ -27,6 +29,9 @@ class Example extends React.Component { {/* Normal Icon */} + + + {/* Icon button */} {} declare const MaskedViewBase: Constructor & typeof MaskedViewComponent; export class MaskedViewIOS extends MaskedViewBase {} -export interface ModalProps { +export interface ModalBaseProps { // Only `animated` is documented. The JS code says `animated` is // deprecated and `animationType` is preferred. animated?: boolean; @@ -4784,35 +4784,42 @@ export interface ModalProps { * The `onShow` prop allows passing a function that will be called once the modal has been shown. */ onShow?: (event: NativeSyntheticEvent) => void; +} + +export interface ModalPropsIOS { + /** + * The `presentationStyle` determines the style of modal to show + */ + presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; + /** * The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations. * On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field. - * @platform ios */ - supportedOrientations?: ( - | "portrait" - | "portrait-upside-down" - | "landscape" - | "landscape-left" - | "landscape-right")[]; + supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">; + + /** + * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. + */ + onDismiss?: () => void; + /** * The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed. * The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation. - * @platform ios */ onOrientationChange?: (event?: NativeSyntheticEvent) => void; - /** - * The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed. - * @platform ios - */ - onDismiss?: () => void; - /** - * The `presentationStyle` determines the style of modal to show - * @platform ios - */ - presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen"; } +export interface ModalPropsAndroid { + /** + * Controls whether to force hardware acceleration for the underlying window. + */ + hardwareAccelerated?: boolean; +} + + +export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid; + export class Modal extends React.Component {} /** diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 0399d41321..60c4d89302 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -71,6 +71,7 @@ import { TextInputSubmitEditingEventData, WebView, KeyboardAvoidingView, + Modal, } from "react-native"; declare module "react-native" { @@ -754,3 +755,7 @@ const AlertIOSTest = () => { 'email-address' ); } + +const ModalTest = () => ( + +) diff --git a/types/react-navigation/index.d.ts b/types/react-navigation/index.d.ts index 6e286c2217..31c3269af4 100644 --- a/types/react-navigation/index.d.ts +++ b/types/react-navigation/index.d.ts @@ -11,7 +11,6 @@ // Qibang Sun // Sergei Butko: // Veit Lehmann: -// Roberto Huertas: // Steven Miller // Armando Assuncao // Ciaran Liedeman @@ -19,6 +18,7 @@ // Jérémy Magrin // Luca Campana // Ullrich Schaefer +// Linus Unnebäck // Yosuke Seki // Jake // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -446,7 +446,8 @@ export type NavigationStackAction = | NavigationReplaceAction | NavigationPopAction | NavigationPushAction - | NavigationPopToTopAction; + | NavigationPopToTopAction + | NavigationCompleteTransitionAction; export type NavigationTabAction = | NavigationInitAction @@ -588,7 +589,8 @@ export interface NavigationScreenProp { openDrawer: () => any; closeDrawer: () => any; toggleDrawer: () => any; - getParam: (param: T, fallback?: P[T]) => P[T]; + getParam(param: T, fallback: NonNullable): NonNullable; + getParam(param: T): P[T]; setParams: (newParams: Partial

) => boolean; addListener: ( eventName: 'willBlur' | 'willFocus' | 'didFocus' | 'didBlur', diff --git a/types/react-navigation/react-navigation-tests.tsx b/types/react-navigation/react-navigation-tests.tsx index 3cde3d892c..60ca9b4758 100644 --- a/types/react-navigation/react-navigation-tests.tsx +++ b/types/react-navigation/react-navigation-tests.tsx @@ -497,6 +497,7 @@ const CustomHeaderStack = createStackNavigator({ interface ScreenProps { name: string; + optionalAge?: number; onPlay(): void; } @@ -513,9 +514,16 @@ class SetParamsTest extends React.Component> render() { const name = this.props.navigation.getParam('name'); + const age = this.props.navigation.getParam('optionalAge'); + + // $ExpectType number | undefined + this.props.navigation.getParam('optionalAge'); + + // $ExpectType number + this.props.navigation.getParam('optionalAge', 0); return ( - My name is {name} + My name is {name} and I am {age} years old. ); } } diff --git a/types/react-router-hash-link/index.d.ts b/types/react-router-hash-link/index.d.ts new file mode 100644 index 0000000000..9480f1aef0 --- /dev/null +++ b/types/react-router-hash-link/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for react-router-hash-link 1.2 +// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Sam Baeck +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; +import { LinkProps, NavLinkProps } from 'react-router-dom'; + +export interface HashLinkProps extends LinkProps { + smooth?: boolean; + scroll?: (element: HTMLElement) => void; +} + +export class HashLink extends React.Component {} + +export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {} + +export class NavHashLink extends React.Component {} diff --git a/types/react-router-hash-link/react-router-hash-link-tests.tsx b/types/react-router-hash-link/react-router-hash-link-tests.tsx new file mode 100644 index 0000000000..4c64a1b5c3 --- /dev/null +++ b/types/react-router-hash-link/react-router-hash-link-tests.tsx @@ -0,0 +1,24 @@ +import * as H from 'history'; +import * as React from 'react'; +import { match } from 'react-router'; +import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link'; + +interface Props extends NavHashLinkProps { + extraProp: string; +} + +const getIsActive = (extraProp: string) => (match: match, location: H.Location) => !!extraProp; + +export default function(props: Props) { + const {extraProp, ...rest} = props; + const isActive = getIsActive(extraProp); + return ( + + ); +} + +; + +const acceptRef = (node: HTMLAnchorElement | null) => { +}; +; diff --git a/types/react-router-hash-link/tsconfig.json b/types/react-router-hash-link/tsconfig.json new file mode 100644 index 0000000000..fc830ac41d --- /dev/null +++ b/types/react-router-hash-link/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-router-hash-link-tests.tsx" + ] +} diff --git a/types/react-router-hash-link/tslint.json b/types/react-router-hash-link/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-router-hash-link/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-virtualized/dist/es/Table.d.ts b/types/react-virtualized/dist/es/Table.d.ts index 09e3c2b37e..b66fac389b 100644 --- a/types/react-virtualized/dist/es/Table.d.ts +++ b/types/react-virtualized/dist/es/Table.d.ts @@ -189,13 +189,13 @@ export type RowMouseEventHandlerParams = { index: number; }; index: number; - event: React.SyntheticEvent>; + event: React.MouseEvent; }; export type HeaderMouseEventHandlerParams = { dataKey: string; columnData: any; - event: React.SyntheticEvent>; + event: React.MouseEvent; }; // ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md diff --git a/types/react/index.d.ts b/types/react/index.d.ts index ce586b0869..e8de06ef62 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -1459,6 +1459,7 @@ declare namespace React { interface ImgHTMLAttributes extends HTMLAttributes { alt?: string; crossOrigin?: "anonymous" | "use-credentials" | ""; + decoding?: "async" | "auto" | "sync"; height?: number | string; sizes?: string; src?: string; diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index dc96bdbe46..0cf9898638 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -10,6 +10,7 @@ // Jamie Saunders // Paul Melnikow // Harry Cruse +// Andrew Palugniok // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -917,6 +918,7 @@ export interface XAxisProps extends EventAttributes { // see label section at http://recharts.org/#/en-US/api/XAxis label?: string | number | Label | LabelProps; allowDuplicatedCategory?: boolean; + stroke?: string; } export class XAxis extends React.Component { } @@ -968,6 +970,7 @@ export interface YAxisProps extends EventAttributes { reversed?: boolean; // see label section at http://recharts.org/#/en-US/api/YAxis label?: string | number | Label | LabelProps; + stroke?: string; } export class YAxis extends React.Component { } diff --git a/types/recharts/recharts-tests.tsx b/types/recharts/recharts-tests.tsx index 855a5c9e75..665c0a13de 100644 --- a/types/recharts/recharts-tests.tsx +++ b/types/recharts/recharts-tests.tsx @@ -90,7 +90,7 @@ class Component extends React.Component<{}, ComponentState> { - + diff --git a/types/reconnect-core/index.d.ts b/types/reconnect-core/index.d.ts new file mode 100644 index 0000000000..0a447e7571 --- /dev/null +++ b/types/reconnect-core/index.d.ts @@ -0,0 +1,47 @@ +// Type definitions for reconnect-core 1.3 +// Project: https://www.npmjs.com/package/reconnect-core +// Definitions by: James Bromwell +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Backoff, ExponentialOptions } from "backoff"; +import { EventEmitter } from "events"; +import { Stream } from "stream"; + +declare namespace reconnect { + // TODO: Once DT supports TS 3.0, use new Generic Rest Parameter feature for + // ArgType. Current definitions only support one parameter passed to + // connect() but the library actually allows any number of args. + type CustomModule = + (opts?: ModuleOptions, cb?: (con: ConnectionType) => void) => Instance; + + interface ModuleOptions extends ExponentialOptions { + immediate?: boolean; + failAfter?: number; + onConnect?: (con: ConnectionType) => void; + strategy?: "fibonacci" | "exponential" | Backoff; + } + + interface Instance extends EventEmitter { + connect(opts: ArgType): this; + listen(opts: ArgType): this; + disconnect(): this; + reset(): void; + + readonly connected: boolean; + reconnect: boolean; + + on(event: "backoff", cb: (n: number, delay: number, err?: any) => void): this; + on(event: "connect" | "connection", cb: (con: ConnectionType) => void): this; + on(event: "disconnect", cb: (err?: any) => void): this; + on(event: "error" | "fail", cb: (err: any) => void): this; + on(event: "reconnect", cb: (n: number, delay: number) => void): this; + } +} + +type ConnectFunction = + (this: reconnect.Instance, opts: ArgType) => ConnectionType; +declare function reconnect( + cf: ConnectFunction): reconnect.CustomModule; + +export = reconnect; diff --git a/types/reconnect-core/reconnect-core-tests.ts b/types/reconnect-core/reconnect-core-tests.ts new file mode 100644 index 0000000000..f809224d2f --- /dev/null +++ b/types/reconnect-core/reconnect-core-tests.ts @@ -0,0 +1,44 @@ +import reconnect = require("reconnect-core"); +import { NetConnectOpts, Socket, connect } from "net"; + +// Approximation of example from docs +const module: reconnect.CustomModule = reconnect(arg => { + // TS can't resolve passing even the simplest union types to function overloads :-/ + // (see TS issue #14107) + if (typeof arg === "string") { + return connect(arg); + } else if (typeof arg === "number") { + return connect(arg); + } else { + return connect(arg); + } +}); + +const opts: reconnect.ModuleOptions = { + failAfter: Infinity, + immediate: false, + initialDelay: 1e3, + maxDelay: 30e3, + randomisationFactor: 0, + strategy: "fibonacci", + onConnect: sock => { + sock.on("data", console.log); + }, +}; + +const conn = module(opts); + +conn.on("connect", con => con.address()) + .on("reconnect", (n, delay) => { + n.toExponential(); + delay.toFixed(); + }) + .on("disconnect", console.log) + .on("error", console.log) + .connect(12345); + +conn.disconnect(); + +conn.reconnect = false; + +conn.reset(); diff --git a/types/reconnect-core/tsconfig.json b/types/reconnect-core/tsconfig.json new file mode 100644 index 0000000000..fd7721cde3 --- /dev/null +++ b/types/reconnect-core/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "forceConsistentCasingInFileNames": true, + "lib": [ + "es2016" + ], + "module": "commonjs", + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "target": "es6", + "types": [], + "typeRoots": [ + "../" + ] + }, + "files": [ + "index.d.ts", + "reconnect-core-tests.ts" + ] +} diff --git a/types/reconnect-core/tslint.json b/types/reconnect-core/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/reconnect-core/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/select2/select2-tests.ts b/types/select2/select2-tests.ts index b3ce0d5896..a351dcc178 100644 --- a/types/select2/select2-tests.ts +++ b/types/select2/select2-tests.ts @@ -774,7 +774,7 @@ const selectedData: Select2.OptionData[] = $("#mySelect2").select2("data"); // jQuery Generic declare let select: HTMLSelectElement; -const $select: JQuery = $(select) as JQuery; +const $select: JQuery = $(select); select = $select.select2().get(0); select = $select.select2({tags: true}).get(0); diff --git a/types/shallow-equals/index.d.ts b/types/shallow-equals/index.d.ts new file mode 100644 index 0000000000..7d91b03923 --- /dev/null +++ b/types/shallow-equals/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for shallow-equals 1.0 +// Project: https://github.com/hughsk/shallow-equals +// Definitions by: Ross Solomon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shallow_equals; + +declare function shallow_equals( + a?: A, + b?: B, + compare?: (objA: A, objB: B) => boolean, +): boolean; diff --git a/types/shallow-equals/shallow-equals-tests.ts b/types/shallow-equals/shallow-equals-tests.ts new file mode 100644 index 0000000000..87512c9f43 --- /dev/null +++ b/types/shallow-equals/shallow-equals-tests.ts @@ -0,0 +1,19 @@ +import shallowEquals = require('shallow-equals'); + +interface A { + foo: string; +} + +interface B { + foo: string; + bar?: string; +} + +const a: A = { foo: 'bar' }; +const b: B = { foo: 'baz' }; +function compare(a: A, b: B) { + return false; +} + +shallowEquals(a, b); +shallowEquals(a, b, compare); diff --git a/types/shallow-equals/tsconfig.json b/types/shallow-equals/tsconfig.json new file mode 100644 index 0000000000..83137182f4 --- /dev/null +++ b/types/shallow-equals/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "shallow-equals-tests.ts"] +} diff --git a/types/shallow-equals/tslint.json b/types/shallow-equals/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/shallow-equals/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/sql-bricks/index.d.ts b/types/sql-bricks/index.d.ts index ccc7e523a7..41cc6b9146 100644 --- a/types/sql-bricks/index.d.ts +++ b/types/sql-bricks/index.d.ts @@ -230,10 +230,10 @@ declare namespace SqlBricks { interface UpdateStatement extends Statement { values(...values: any[]): UpdateStatement set(...values: any[]): UpdateStatement - where(column?: string | null, value?: any): SelectStatement - where(...whereExpr: WhereExpression[]): SelectStatement - and(column?: string | null, value?: any): SelectStatement - and(...whereExpr: WhereExpression[]): SelectStatement + where(column?: string | null, value?: any): UpdateStatement + where(...whereExpr: WhereExpression[]): UpdateStatement + and(column?: string | null, value?: any): UpdateStatement + and(...whereExpr: WhereExpression[]): UpdateStatement } /** diff --git a/types/steam-login/index.d.ts b/types/steam-login/index.d.ts new file mode 100644 index 0000000000..849a45b920 --- /dev/null +++ b/types/steam-login/index.d.ts @@ -0,0 +1,61 @@ +// Type definitions for steam-login 0.1 +// Project: http://github.com/cpancake/steam-login +// Definitions by: Nick Winans +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Request, RequestHandler } from 'express'; + +export interface MiddlewareOptions { + verify: string; + realm: string; + apiKey: string; + useSession?: boolean; +} + +export interface SteamUser { + _json: { + steamid: string; + personaname: string; + profileurl: string; + avatar: string; + avatarmedium: string; + avatarfull: string; + personastate: number; + communityvisibilitystate: number; + profilestate?: number; + lastlogoff: number; + commentpermission?: number; + realname?: string; + primaryclanid?: string; + timecreated?: number; + gameid?: string; + gameserverip?: string; + gameextrainfo?: string; + loccountrycode?: string; + locstatecode?: string; + loccityid?: number; + }; + steamid: string; + username: string; + name: string; + profile: string; + avatar: { + small: string; + medium: string; + large: string; + }; +} + +export interface SteamRequest extends Request { + logout?(): (req: Request) => () => void; + user?: SteamUser; +} + +export function middleware(opts: MiddlewareOptions): RequestHandler; + +export function enforceLogin(redirect: string): RequestHandler; + +export function verify(): RequestHandler; + +export function authenticate(): RequestHandler; diff --git a/types/steam-login/steam-login-tests.ts b/types/steam-login/steam-login-tests.ts new file mode 100644 index 0000000000..84eae31a01 --- /dev/null +++ b/types/steam-login/steam-login-tests.ts @@ -0,0 +1,35 @@ +// Port of https://github.com/cpancake/steam-login/blob/master/example.js + +import * as express from 'express'; +import * as steam from 'steam-login'; +import * as session from 'express-session'; + +const app = express(); + +app.use(session({ resave: false, saveUninitialized: false, secret: 'a secret' })); +app.use(steam.middleware({ + realm: 'http://localhost:3000/', + verify: 'http://localhost:3000/verify', + apiKey: process.argv[2] +} +)); + +app.get('/', (req: steam.SteamRequest, res) => { + res.send(req.user == null ? 'not logged in' : 'hello ' + req.user.username).end(); +}); + +app.get('/authenticate', steam.authenticate(), (req, res) => { + res.redirect('/'); +}); + +app.get('/verify', steam.verify(), (req: steam.SteamRequest, res) => { + res.send(req.user).end(); +}); + +app.get('/logout', steam.enforceLogin('/'), (req: steam.SteamRequest, res) => { + req.logout ? req.logout() : null; + res.redirect('/'); +}); + +app.listen(3000); +console.log('listening'); diff --git a/types/steam-login/tsconfig.json b/types/steam-login/tsconfig.json new file mode 100644 index 0000000000..8548e16277 --- /dev/null +++ b/types/steam-login/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", + "steam-login-tests.ts" + ] +} diff --git a/types/steam-login/tslint.json b/types/steam-login/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/steam-login/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/styled-system/dist/util.d.ts b/types/styled-system/dist/util.d.ts index f91b2b6620..ae90de60f8 100644 --- a/types/styled-system/dist/util.d.ts +++ b/types/styled-system/dist/util.d.ts @@ -19,7 +19,7 @@ export interface LowLevelStylefunctionArguments { cssProperty?: string; key?: string; getter?: () => any; - transformValue?: () => any; + transformValue?: (n: string|number) => any; scale?: Array; } diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index 6062948a50..c0f9ba9ded 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -1,6 +1,4 @@ -// Example uses styled-components, but styled-system works with most other css-in-js libraries as well import * as React from "react"; -import styled from "styled-components"; import { themeGet, space, @@ -125,6 +123,9 @@ import { MixedProps, } from "styled-system"; +// tslint:disable-next-line:strict-export-declare-modifiers +declare const styled: (...props: any[]) => React.ComponentType; + const boxStyle = variant({ prop: 'boxStyle', key: 'box', @@ -168,9 +169,8 @@ interface BoxProps MixedProps { boxStyle?: string; } -const Box = styled.div.attrs({})` - -border-radius: ${themeGet("radii.small", "4px")}; +const Box: React.ComponentType = styled` + border-radius: ${themeGet("radii.small", "4px")}; ${space} ${width} ${fontSize} @@ -226,7 +226,7 @@ interface TextProps LineHeightProps, FontWeightProps, LetterSpacingProps {} -const Text = styled.div.attrs({})` +const Text: React.ComponentType = styled` ${fontSize}; ${fontFamily}; ${textAlign}; @@ -242,7 +242,7 @@ interface FlexComponentProps FlexWrapProps, FlexBasisProps, FlexDirectionProps {} -const Flex = styled.div.attrs({})` +const Flex: React.ComponentType = styled` ${alignItems}; ${alignContent}; ${justifyContent}; @@ -262,7 +262,7 @@ interface GridComponentProps GridAutoRowsProps, GridTemplatesRowsProps, GridTemplatesColumnsProps {} -const Grid = styled.div.attrs({})` +const Grid: React.ComponentType = styled` ${gridGap}; ${gridRowGap}; ${gridColumnGap}; @@ -279,7 +279,7 @@ interface ButtonProps extends SpaceProps, ButtonStyleProps {} -const TestButton = styled.button.attrs({})` +const TestButton: React.ComponentType = styled` ${buttonStyle} ${space} `; diff --git a/types/superagent-bunyan/index.d.ts b/types/superagent-bunyan/index.d.ts new file mode 100644 index 0000000000..1dfec979e4 --- /dev/null +++ b/types/superagent-bunyan/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for superagent-bunyan 5.2 +// Project: https://github.com/joaquimserafim/superagent-bunyan#readme +// Definitions by: Alex Brick +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import * as Logger from 'bunyan'; +import { Plugin } from 'superagent'; + +declare function superagentLogger(logger: Logger, requestId?: string, extra?: object): Plugin; + +export = superagentLogger; diff --git a/types/superagent-bunyan/superagent-bunyan-tests.ts b/types/superagent-bunyan/superagent-bunyan-tests.ts new file mode 100644 index 0000000000..3a6f973e91 --- /dev/null +++ b/types/superagent-bunyan/superagent-bunyan-tests.ts @@ -0,0 +1,16 @@ +import * as request from 'superagent'; +import * as bunyan from 'bunyan'; + +import superagentLogger = require('superagent-bunyan'); + +const logger = bunyan.createLogger({name: 'my_log'}); + +logger.info('Hey!'); + +request + .get('http://localhost:3000') + .use(superagentLogger(logger)) + .use(superagentLogger(logger, 'requestId')) + .use(superagentLogger(logger, 'requestId', { foo: 'bar' })) + .use(superagentLogger(logger, undefined, { foo: 'bar' })) + .end((err, res) => {}); diff --git a/types/superagent-bunyan/tsconfig.json b/types/superagent-bunyan/tsconfig.json new file mode 100644 index 0000000000..0118838dcd --- /dev/null +++ b/types/superagent-bunyan/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", + "superagent-bunyan-tests.ts" + ] +} diff --git a/types/superagent-bunyan/tslint.json b/types/superagent-bunyan/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/superagent-bunyan/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ttf2woff2/index.d.ts b/types/ttf2woff2/index.d.ts new file mode 100644 index 0000000000..180c64f93e --- /dev/null +++ b/types/ttf2woff2/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for ttf2woff2 2.0 +// Project: https://github.com/nfroidure/ttf2woff2 +// Definitions by: Thomas den Hollander +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function ttf2woff2(inputContent: Buffer): Buffer; + +export = ttf2woff2; diff --git a/types/ttf2woff2/tsconfig.json b/types/ttf2woff2/tsconfig.json new file mode 100644 index 0000000000..0b6fc9778b --- /dev/null +++ b/types/ttf2woff2/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true + }, + "files": [ + "index.d.ts", + "ttf2woff2-tests.ts" + ] +} diff --git a/types/ttf2woff2/tslint.json b/types/ttf2woff2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ttf2woff2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ttf2woff2/ttf2woff2-tests.ts b/types/ttf2woff2/ttf2woff2-tests.ts new file mode 100644 index 0000000000..71b5a16d65 --- /dev/null +++ b/types/ttf2woff2/ttf2woff2-tests.ts @@ -0,0 +1,4 @@ +import ttf2woff2 = require('ttf2woff2'); + +const input = Buffer.alloc(10); +const result: Buffer = ttf2woff2(input); diff --git a/types/uid-safe/index.d.ts b/types/uid-safe/index.d.ts index ee7b13491f..20a85ae899 100644 --- a/types/uid-safe/index.d.ts +++ b/types/uid-safe/index.d.ts @@ -8,7 +8,7 @@ declare namespace UID { export interface Generate { (byteLength: number, callback: (err: any, str: string) => any): void; - (byteLength: number): Promise; + (byteLength: number): Promise; sync(byteLength: number): string; } diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 8822deca98..72498e3591 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,13 +1,13 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman , Ard Timmerman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; export = _; export as namespace _; -// The DOM is not required to be present, but these definitions reference type Element for the +// The DOM is not required to be present, but these definitions reference type Element for the // isElement check. If the DOM is present, this declaration will merge. declare global { interface Element { } @@ -3631,7 +3631,7 @@ declare module _ { * @param object Convert this object to a list of [key, value] pairs. * @return List of [key, value] pairs on `object`. **/ - pairs(object: any): any[][]; + pairs(object: any): [string, any][]; /** * Returns a copy of the object where the keys have become the values and the values the keys. @@ -4738,7 +4738,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): any[][]; + pairs(): [string, any][]; /** * Wrapped type `object`. @@ -5692,7 +5692,7 @@ declare module _ { * Wrapped type `object`. * @see _.values **/ - values(): _Chain; + values(): _Chain; /** * Wrapped type `object`. @@ -5704,7 +5704,7 @@ declare module _ { * Wrapped type `object`. * @see _.pairs **/ - pairs(): _Chain; + pairs(): _Chain<[string, any]>; /** * Wrapped type `object`. diff --git a/types/underscore/underscore-tests.ts b/types/underscore/underscore-tests.ts index 419479f689..6175c1874b 100644 --- a/types/underscore/underscore-tests.ts +++ b/types/underscore/underscore-tests.ts @@ -527,6 +527,16 @@ function chain_tests() { .keys() // return ['foo', 'bar'] : string[] .pairs() // return [['foo', '0'], ['bar', '1']] : string[][] .value(); + + interface IYears { + 2016: number; + 2017: number; + } + + let yearObject: IYears = {2016: 1, 2017: 2}; + let valuePerYear: number[] = _.chain(yearObject) + .values() + .value() } var obj: { [k: string] : number } = { diff --git a/types/universal-cookie/index.d.ts b/types/universal-cookie/index.d.ts new file mode 100644 index 0000000000..4bba4adee6 --- /dev/null +++ b/types/universal-cookie/index.d.ts @@ -0,0 +1,102 @@ +// Type definitions for universal-cookie 2.2 +// Project: https://github.com/reactivestack/cookies/tree/master/packages/universal-cookie#readme +// Definitions by: Tomi Turtiainen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export interface CookiesByName { + [cookieName: string]: string; +} + +export interface GetOpts { + /** + * do not convert the cookie into an object no matter what + */ + doNotParse: boolean; +} + +export interface CookieOpts { + /** + * cookie path, use / as the path if you want your cookie to be accessible on all pages + */ + path?: string; + + /** + * absolute expiration date for the cookie + */ + expires?: Date; + + /** + * relative max age of the cookie from when the client receives it in second + */ + maxAge?: number; + + /** + * domain for the cookie (sub.domain.com or .allsubdomains.com) + */ + domain?: string; + + /** + * Is only accessible through HTTPS? + */ + secure?: boolean; + + /** + * Is only the server can access the cookie? + */ + httpOnly?: boolean; +} + +export type ChangeListenerCallback = ( + name: string, + value: string | object, + options: CookieOpts +) => void; + +export default class Cookies { + constructor(cookieHeader?: string | CookiesByName); + + /** + * Get a cookie value + * + * @param name cookie name + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + get(name: string, options?: GetOpts): string; + + /** + * Get all cookies + * + * @param options.doNotParse do not convert the cookie into an object no matter what + */ + getAll(options?: GetOpts): CookiesByName; + + /** + * Set a cookie value + * + * @param name cookie name + * @param value save the value and stringify the object if needed + * @param options Support all the cookie options from RFC 6265 + */ + set(name: string, value: string | object, options?: CookieOpts): void; + + /** + * Set a cookie value + * + * @param name cookie name + * @param options Support all the cookie options from RFC 6265 + */ + remove(name: string, options?: CookieOpts): void; + + /** + * Add a listener to when a cookie is set or removed. + * + * @param callback Call that will be called with the first argument containing name, value and options of the changed cookie. + */ + addChangeListener(callback: ChangeListenerCallback): void; + + /** + * Remove a listener from the change callback. + */ + removeChangeListener(callback: ChangeListenerCallback): void; +} diff --git a/types/universal-cookie/tsconfig.json b/types/universal-cookie/tsconfig.json new file mode 100644 index 0000000000..1c324ed8c6 --- /dev/null +++ b/types/universal-cookie/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "universal-cookie-tests.ts"] +} diff --git a/types/universal-cookie/tslint.json b/types/universal-cookie/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/universal-cookie/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/universal-cookie/universal-cookie-tests.ts b/types/universal-cookie/universal-cookie-tests.ts new file mode 100644 index 0000000000..9591fa3c5b --- /dev/null +++ b/types/universal-cookie/universal-cookie-tests.ts @@ -0,0 +1,20 @@ +import Cookies from "universal-cookie"; + +const cookies = new Cookies(); +new Cookies("My=Cookie"); +new Cookies({}); + +cookies.set("my", "cookie"); +cookies.set("object", { some: "value" }); +cookies.set("with", "options", { + path: "/" +}); + +cookies.get("my"); +cookies.getAll(); + +cookies.remove("object"); +cookies.remove("object", { path: "/" }); + +cookies.addChangeListener((name, value) => {}); +cookies.removeChangeListener((name, value) => {}); diff --git a/types/varint/index.d.ts b/types/varint/index.d.ts new file mode 100644 index 0000000000..ec490a2e70 --- /dev/null +++ b/types/varint/index.d.ts @@ -0,0 +1,46 @@ +// Type definitions for varint 5.0 +// Project: https://github.com/chrisdickinson/varint#readme +// Definitions by: David Brockman Smoliansky +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export const encode: { + /** + * Encodes `num` into `buffer` starting at `offset`. returns `buffer`, with the encoded varint written into it. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, buffer: Buffer, offset?: number): Buffer; + + /** + * Encodes `num` into `array` starting at `offset`. returns `array`, with the encoded varint written into it. + * If `array` is not provided, it will default to a new array. + * `varint.encode.bytes` will now be set to the number of bytes modified. + */ + (num: number, array?: number[], offset?: number): number[]; + + /** + * Similar to `decode.bytes` when encoding a number it can be useful to know how many bytes where written (especially if you pass an output array). + * You can access this via `varint.encode.bytes` which holds the number of bytes written in the last encode. + */ + bytes: number; +}; + +export const decode: { + /** + * Decodes `data`, which can be either a buffer or array of integers, from position `offset` or default 0 and returns the decoded original integer. + * Throws a `RangeError` when `data` does not represent a valid encoding. + */ + (buf: Buffer | number[], offset?: number): number; + + /** + * If you also require the length (number of bytes) that were required to decode the integer you can access it via `varint.decode.bytes`. + * This is an integer property that will tell you the number of bytes that the last .decode() call had to use to decode. + */ + bytes: number; +}; + +/** + * returns the number of bytes this number will be encoded as, up to a maximum of 8. + */ +export function encodingLength(num: number): number; diff --git a/types/varint/tsconfig.json b/types/varint/tsconfig.json new file mode 100644 index 0000000000..269a7016fe --- /dev/null +++ b/types/varint/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "varint-tests.ts"] +} diff --git a/types/varint/tslint.json b/types/varint/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/varint/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/varint/varint-tests.ts b/types/varint/varint-tests.ts new file mode 100644 index 0000000000..4ef8c91753 --- /dev/null +++ b/types/varint/varint-tests.ts @@ -0,0 +1,17 @@ +import { decode, encode, encodingLength } from 'varint'; + +encode(0); // $ExpectType number[] +encode(0, []); // $ExpectType number[] +encode(0, [], 0); // $ExpectType number[] + +encode(0, Buffer.alloc(1)); // $ExpectType Buffer +encode(0, Buffer.alloc(1), 0); // $ExpectType Buffer + +encode.bytes; // $ExpectType number + +decode(Buffer.alloc(1)); // $ExpectType number +decode(Buffer.alloc(1), 0); // $ExpectType number + +decode.bytes; // $ExpectType number + +encodingLength(0); // $ExpectType number diff --git a/types/vimeo__player/index.d.ts b/types/vimeo__player/index.d.ts index 6fac1db7d9..cf7475f246 100755 --- a/types/vimeo__player/index.d.ts +++ b/types/vimeo__player/index.d.ts @@ -111,6 +111,4 @@ export interface VimeoPromise extends Promise { } /*~ You can declare properties of the module using const, let, or var */ -export const playerMap: WeakMap; -export const readyMap: WeakMap; export default Player; diff --git a/types/webpack-dev-server/index.d.ts b/types/webpack-dev-server/index.d.ts index dab8ae5467..435d2547d9 100644 --- a/types/webpack-dev-server/index.d.ts +++ b/types/webpack-dev-server/index.d.ts @@ -14,6 +14,7 @@ import * as express from 'express'; import * as serveStatic from 'serve-static'; import * as https from 'https'; import * as http from 'http'; +import { Url } from "url"; declare namespace WebpackDevServer { interface ListeningApp { @@ -31,9 +32,16 @@ declare namespace WebpackDevServer { type ProxyConfigArray = ProxyConfigArrayItem[]; + interface Context { + match: RegExpMatchArray; + parsedUrl: Url; + } + + type RewriteTo = (context: Context) => string; + interface Rewrite { from: RegExp; - to: string; + to: string | RegExp | RewriteTo; } interface HistoryApiFallbackConfig { diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index a228afc242..664439523b 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -117,7 +117,7 @@ declare namespace webpack { [name: string]: string | string[]; } - type EntryFunc = () => (string | string[] | Promise); + type EntryFunc = () => (string | string[] | Entry | Promise); interface DevtoolModuleFilenameTemplateInfo { identifier: string; diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 2f75d11b31..16234d422a 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -55,6 +55,14 @@ configuration = { entry: () => ['./demo', './demo2'] }; +configuration = { + entry: () => ({ + p1: "./page1", + p2: "./page2", + p3: "./page3" + }) +}; + configuration = { entry: () => new Promise((resolve) => resolve('./demo')) }; @@ -63,6 +71,14 @@ configuration = { entry: () => new Promise((resolve) => resolve(['./demo', './demo2'])) }; +configuration = { + entry: () => new Promise((resolve) => resolve({ + p1: "./page1", + p2: "./page2", + p3: "./page3" + })) +}; + // // https://webpack.github.io/docs/optimization.html // diff --git a/types/yup/index.d.ts b/types/yup/index.d.ts index b4c8ea797e..2dcf110a9e 100644 --- a/types/yup/index.d.ts +++ b/types/yup/index.d.ts @@ -55,7 +55,7 @@ export interface Schema { oneOf(arrayOfValues: any[], message?: string): this; notOneOf(arrayOfValues: any[], message?: string): this; when(keys: string | any[], builder: WhenOptions): this; - test(name: string, message: string, test: (this: TestContext, value?: any) => boolean | Promise, callbackStyleAsync?: boolean): this; + test(name: string, message: string, test: (this: TestContext, value?: any) => boolean | ValidationError | Promise, callbackStyleAsync?: boolean): this; test(options: TestOptions): this; transform(fn: TransformFunction): this; } @@ -202,7 +202,7 @@ export interface TestOptions { /** * Test function, determines schema validity */ - test: (this: TestContext, value: any) => boolean | Promise; + test: (this: TestContext, value: any) => boolean | ValidationError | Promise; /** * The validation error message diff --git a/types/yup/yup-tests.ts b/types/yup/yup-tests.ts index 2d5b509b37..c6f367a043 100644 --- a/types/yup/yup-tests.ts +++ b/types/yup/yup-tests.ts @@ -141,6 +141,26 @@ mixed.test({ test: testContext }); +// Async ValidationError +const asyncValidationErrorTest = function(this: TestContext): Promise { + return new Promise(resolve => resolve(this.createError({ path: "testPath", message: "testMessage" }))); +}; + +mixed.test('async-validation-error', 'Returns async ValidationError', asyncValidationErrorTest); +mixed.test({ + test: asyncValidationErrorTest, +}); + +// Sync ValidationError +const syncValidationErrorTest = function(this: TestContext): ValidationError { + return this.createError({ path: "testPath", message: "testMessage" }); +}; + +mixed.test('sync-validation-error', 'Returns sync ValidationError', syncValidationErrorTest); +mixed.test({ + test: syncValidationErrorTest, +}); + yup.string().transform(function(this, value: any, originalvalue: any) { return this.isType(value) && value !== null ? value.toUpperCase() : value; });