From e41c10f1a3c85ca8e4e344e65d094bd24cb2d179 Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 29 Jul 2016 21:09:20 -0700 Subject: [PATCH 1/3] [Types-2.0] Merge master 07/29 (#10365) * Including typings for globalize-compiler. * Updating typings for globalize-compiler to use the correct AST type. * Changed AtomicBlockUtils and KeyBindingUtil from interfaces to classes with static functions (#10324) * Fixing a few minor issues in webpack-stream. (#10253) * Document changes in 0.28 and 0.29 in React Native (#10309) * RN: Widen limit of refreshControl * RN: Update NavigationExperimental to 0.28 * RN: Define new method from 0.28 * RN: Promisify requestPermissions per 0.28 * RN: Remove onNavigate method See: https://github.com/facebook/react-native/commit/fb0007d85323909ab652bf97166744fa7e17daab#diff-04c37ff76f85aea35e8475617539b75fR94 * RN: Add onNavigateBack method See: https://github.com/facebook/react-native/commit/fb0007d85323909ab652bf97166744fa7e17daab#diff-04c37ff76f85aea35e8475617539b75fR94 * RN: Deprecate StatusBarIOS * RN: Update StyleSheet API per 0.29 * RN: Define KeyboardAvoidingView added in 0.29 * RN: Define saveToCameraRoll added in 0.29 * RN: Define cancellable from InteractionManager * RN: Add new possible values of flexDirection * RN: Define lineBreakMode * RN: Allow zIndex prop * RN: Allow dimension limits * RN: Specify type of refreshControl * RN: Mark properties as optional * RN: Clarify parameter naming * RN: Mark optional property as optional * RN: Definite explicit ref type * RN: Restore StyleSheet.create to restore compatibility * Added Headers constructor options to whatwg-fetch (#10313) * Impl: Updated definitions for oracledb (#10323) * Update select2 to have selectOnClose option (#10326) Option documented at https://select2.github.io/options.html#can-i-select-the-highlighted-result-when-the-dropdown-is-closed * Added definition for react-file-input React component (#10325) * Added definition for react-file-input React component * Added newline at end of file * Added definitions for the react-file-reader-input react component. (#10327) * Sleep (#10333) * Add Electron specific versions to process.versions (#10320) * Fix uuid.js definitions. (#10318) * protobufjs: updated Message interfaces (#10198) * protobufjs: updated Message interfaces * Added ProtoBuf.Util interface * Fixed load functions of ProtoBuf namespace Base on the protobuf.js API docmentation. * use {} instead of Object Fixed according to PR commit note. * Multiple minor fixes (#10339) * better typing of onShouldStartLoadWithRequest in WebViewPropertiesIOS * Fixes to WebViewProperties * Missing methods in Navigator * Fix of Platform.select() * added support for interfacing with native-modules * added support for interfacing with native-modules * added dev variable * Update to header notes * Examples: alternative styles declaration * webcomponents.js: Add typings for Element.createShadowRoot (#10330) * webcomponents.js: Add typings for Element.createShadowRoot createShadowRoot is deprecated in the official Shadow DOM spec, but is the way to attach a shadow root in the current released version of webcomponents.js. * webcomponents.js: remove spurious extra line * webcomponents.js: remove readonly modifier Not supported until TS2. * webcomponents.js: add Element.shadowRoot property * Adding a couple missing highcharts properites (#10340) * Adding a couple missing highcharts properites * Fixing indentation * Indentation * Update to Electron 1.3.1 (#10336) * Update to Electron 1.3.1 * Update editing command docs * Fix argument types * add definition of js-priority-queue (#10347) * Update to v1.13.0 and bug fix: sanitize-html expects tag attributes to be called attribs. (#10360) * updated vue-resource (#10349) * Updated to match docs for version 0.9.3 (latest as of 07/19/16) This is very important because response.data now returns raw data instead of a json object, you need to use res.json() to get an object representation of the response. .json() was missing from the typings. Aditionally modified a few breaking changes to match the documentation at: https://github.com/vuejs/vue-resource/blob/master/docs/http.md * Added tests for json, blob, and text * fixed version number * Move change from master to corresponding index.d.ts --- electron/index.d.ts | 61 ++++++---- .../globalize-compiler-tests.ts | 36 ++++++ globalize-compiler/globalize-compiler.d.ts | 106 ++++++++++++++++++ highcharts/index.d.ts | 5 - js-priority-queue/js-priority-queue-tests.ts | 26 +++++ js-priority-queue/js-priority-queue.d.ts | 64 +++++++++++ oracledb/oracledb-tests.ts | 1 - protobufjs/index.d.ts | 3 +- sanitize-html/index.d.ts | 64 ++++++----- sanitize-html/sanitize-html-tests.ts | 12 +- uuid/UUID-tests.ts | 1 - vue-resource/index.d.ts | 17 +-- vue-resource/vue-resource-tests.ts | 3 + whatwg-fetch/whatwg-fetch-tests.ts | 13 +++ 14 files changed, 345 insertions(+), 67 deletions(-) create mode 100644 globalize-compiler/globalize-compiler-tests.ts create mode 100644 globalize-compiler/globalize-compiler.d.ts create mode 100644 js-priority-queue/js-priority-queue-tests.ts create mode 100644 js-priority-queue/js-priority-queue.d.ts diff --git a/electron/index.d.ts b/electron/index.d.ts index 3c0a247332..36d580ccb4 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -401,7 +401,7 @@ declare namespace Electron { * Note: This will not affect process.argv, and is mainly used by developers * to control some low-level Chromium behaviors. */ - appendSwitch(_switch: string, value?: string|number): void; + appendSwitch(_switch: string, value?: string): void; /** * Append an argument to Chromium's command line. The argument will quoted properly. * @@ -2799,7 +2799,7 @@ declare namespace Electron { /** * Sets the proxy settings. */ - setProxy(config: string, callback: Function): void; + setProxy(config: ProxyConfig, callback: Function): void; /** * Resolves the proxy information for url. */ @@ -2882,6 +2882,21 @@ declare namespace Electron { quotas?: ('temporary' | 'persistent' | 'syncable')[]; } + interface ProxyConfig { + /** + * The URL associated with the PAC file. + */ + pacScript: string; + /** + * Rules indicating which proxies to use. + */ + proxyRules: string; + /** + * Rules indicating which URLs should bypass the proxy settings. + */ + proxyBypassRules: string; + } + interface NetworkEmulationOptions { /** * Whether to emulate network outage. @@ -3386,10 +3401,10 @@ declare namespace Electron { */ setTitle(title: string): void; /** - * Sets whether the tray icon is highlighted when it is clicked. + * Sets when the tray's icon background becomes highlighted. * Note: This is only implemented on macOS. */ - setHighlightMode(highlight: boolean): void; + setHighlightMode(mode: 'selection' | 'always' | 'never'): void; /** * Displays a tray balloon. * Note: This is only implemented on Windows. @@ -3641,6 +3656,10 @@ declare namespace Electron { * passing empty string to callback will cancel the request. */ on(event: 'select-bluetooth-device', listener: (event: Event, deviceList: BluetoothDevice[], callback: (deviceId: string) => void) => void): this; + /** + * Emitted when a page's view is repainted. + */ + on(event: 'view-painted', listener: Function): this; on(event: string, listener: Function): this; /** * Loads the url in the window. @@ -3751,47 +3770,51 @@ declare namespace Electron { */ isAudioMuted(): boolean; /** - * Executes Edit -> Undo command in page. + * Executes the editing command undo in web page. */ undo(): void; /** - * Executes Edit -> Redo command in page. + * Executes the editing command redo in web page. */ redo(): void; /** - * Executes Edit -> Cut command in page. + * Executes the editing command cut in web page. */ cut(): void; /** - * Executes Edit -> Copy command in page. + * Executes the editing command copy in web page. */ copy(): void; /** - * Executes Edit -> Paste command in page. + * Copy the image at the given position to the clipboard. + */ + copyImageAt(x: number, y: number): void; + /** + * Executes the editing command paste in web page. */ paste(): void; /** - * Executes Edit -> Paste and Match Style in page. + * Executes the editing command pasteAndMatchStyle in web page. */ pasteAndMatchStyle(): void; /** - * Executes Edit -> Delete command in page. + * Executes the editing command delete in web page. */ delete(): void; /** - * Executes Edit -> Select All command in page. + * Executes the editing command selectAll in web page. */ selectAll(): void; /** - * Executes Edit -> Unselect command in page. + * Executes the editing command unselect in web page. */ unselect(): void; /** - * Executes Edit -> Replace command in page. + * Executes the editing command replace in web page. */ replace(text: string): void; /** - * Executes Edit -> Replace Misspelling command in page. + * Executes the editing command replaceMisspelling in web page. */ replaceMisspelling(text: string): void; /** @@ -3894,10 +3917,10 @@ declare namespace Electron { * The callback will be called when there is a presentation event. */ beginFrameSubscription(onlyDirty: boolean, callback: BeginFrameSubscriptionCallback): void; - /** + /** * Begin subscribing for presentation events and captured frames, * The callback will be called when there is a presentation event. - */ + */ beginFrameSubscription(callback: BeginFrameSubscriptionCallback): void; /** * End subscribing for frame presentation events. @@ -4342,7 +4365,7 @@ declare namespace Electron { wheelTicksY?: number; accelerationRatioX?: number; accelerationRatioY?: number; - hasPreciseScrollingDeltas?: number; + hasPreciseScrollingDeltas?: boolean; canScroll?: boolean; } @@ -4619,7 +4642,7 @@ declare namespace Electron { /** * Navigates to the specified offset from the "current entry". */ - goToOffset(offset: boolean): void; + goToOffset(offset: number): void; /** * @returns Whether the renderer process has crashed. */ diff --git a/globalize-compiler/globalize-compiler-tests.ts b/globalize-compiler/globalize-compiler-tests.ts new file mode 100644 index 0000000000..f4fc934d1f --- /dev/null +++ b/globalize-compiler/globalize-compiler-tests.ts @@ -0,0 +1,36 @@ +/// + +import globalizeCompiler = require("globalize-compiler"); +const globalize: GlobalizeStatic = null; + +let extractsArray: GlobalizeCompiler.FormatterOrParserFunction[]; + +const templateFunction: (options: GlobalizeCompiler.CompileTemplateOptions) => string = + (options: GlobalizeCompiler.CompileTemplateOptions): string => { + const deps: string[] = options.dependencies; + const code: string = options.code; + return `${deps.join(';')}${code}`; + }; + +let compileOutput: string; +compileOutput = globalizeCompiler.compile(extractsArray); +compileOutput = globalizeCompiler.compile({ x: () => "test", y: (x: string) => x }); +compileOutput = globalizeCompiler.compile(extractsArray, { template: templateFunction }); +compileOutput = globalizeCompiler.compile({ x: () => "test", y: (x: string) => x }, { template: templateFunction }); + +let extractOutput: GlobalizeCompiler.ExtractFunction; +extractOutput = globalizeCompiler.extract("path"); + +const ast: ESTree.Program = undefined; +extractOutput = globalizeCompiler.extract(ast); + +extractsArray = extractOutput(globalize); + +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en" }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", messages: {} }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", template: templateFunction }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", messages: {}, template: templateFunction }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", cldr: {} }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", cldr: {}, messages: {} }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", cldr: {}, template: templateFunction }); +compileOutput = globalizeCompiler.compileExtracts({ extracts: extractOutput, defaultLocale: "en", cldr: {}, messages: {}, template: templateFunction }); diff --git a/globalize-compiler/globalize-compiler.d.ts b/globalize-compiler/globalize-compiler.d.ts new file mode 100644 index 0000000000..3959924412 --- /dev/null +++ b/globalize-compiler/globalize-compiler.d.ts @@ -0,0 +1,106 @@ +// Type definitions for globalize-compiler v0.2.0 +// Project: https://github.com/jquery-support/globalize-compiler +// Definitions by: Ian Clanton-Thuon +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare namespace GlobalizeCompiler { + interface CompileTemplateOptions { + /** + * the source of the compiled formatters and parsers. + */ + code: string; + + /** + * a list of globalize runtime modules that the compiled code depends on, e.g. globalize-runtime/number. + */ + dependencies: string[]; + } + + interface CompileOptions { + /** + * A function that replaces the default template. + */ + template?: (options: CompileTemplateOptions) => string; + } + + interface FormatterOrParserFunction { + (...arguments: any[]): any; + } + + interface ExtractFunction { + /** + * @param {globalize} the globalize object. + * + * @returns an Array with the formatters and parsers created using the passed Globalize. + */ + (globalize: GlobalizeStatic): FormatterOrParserFunction[]; + } + + interface CompileExtractsAttributes extends CompileOptions { + /** + * an Array of extracts obtained by @see{GlobalizeCompilerStatic.extract} + */ + extracts: ExtractFunction; + + /** + * a locale to be used as Globalize.locale(defaultLocale) when generating the extracted formatters and parsers. + */ + defaultLocale: string; + + /** + * an Object with CLDR data (in the JSON format) or a Function taking one argument: locale, a String; returning + * an Object with the CLDR data for the passed locale. Defaults to the entire supplemental data plus the entire + * main data for the defaultLocale. + */ + cldr?: Object | ((locale: string) => Object); + + /** + * an Object with messages data (in the JSON format) or a Function taking one argument: locale, a String; returning + * an Object with the messages data for the passed locale. Defaults to {}. + */ + messages?: Object | ((locale: string) => Object); + } + + interface GlobalizeCompilerStatic { + /** + * Generates a JavaScript bundle containing the specified globalize formatters and parsers. + * + * @param {formattersAndParsers} an Array or an Object containing formatters and/or parsers. + * @param {options} compiler options. + * + * @returns a String with the generated JavaScript bundle (UMD wrapped) including the compiled formatters and + * parsers. + */ + compile(formattersAndParsers: FormatterOrParserFunction[] | { [key: string]: FormatterOrParserFunction }, + options?: CompileOptions): string; + + /** + * Creates an extract function from a source file. + * + * @param {input} a String with a filename, or a String with the file content, or an AST Object. + * + * @returns an extract. An extract is a Function taking one argument: Globalize, the Globalize Object; + * and returning an Array with the formatters and parsers created using the passed Globalize. + */ + extract(input: string | ESTree.Program): ExtractFunction; + + /** + * Generates a JavaScript bundle containing the specified globalize formatters and parsers. + * + * @param {options} compiler attributes. + * + * @returns a String with the generated JavaScript bundle (UMD wrapped) including the compiled formatters and + * parsers. + */ + compileExtracts(attributes: CompileExtractsAttributes): string; + } +} + +declare module "globalize-compiler" { + var globalizeCompiler: GlobalizeCompiler.GlobalizeCompilerStatic; + + export = globalizeCompiler; +} diff --git a/highcharts/index.d.ts b/highcharts/index.d.ts index 311e016dc6..a338f19757 100644 --- a/highcharts/index.d.ts +++ b/highcharts/index.d.ts @@ -724,9 +724,6 @@ interface HighchartsAxisOptions { * @since 1.2.0 */ startOnTick?: boolean; - - stops?: [number, string][]; - /** * The amount of ticks to draw on the axis. This opens up for aligning the ticks of multiple charts or panes within * a chart. This option overrides the tickPixelInterval option. @@ -5475,7 +5472,6 @@ interface HighchartsOptions { * lineWidth is specified in plotOptions.series, an individual lineWidth can be specified for each series. */ series?: HighchartsIndividualSeriesOptions[]; - /** * The chart's subtitle */ @@ -5498,7 +5494,6 @@ interface HighchartsOptions { * horizontal axis. In case of multiple axes, the yAxis node is an array of configuration objects. */ yAxis?: HighchartsAxisOptions[] | HighchartsAxisOptions; - } interface HighchartsGlobalOptions extends HighchartsOptions { diff --git a/js-priority-queue/js-priority-queue-tests.ts b/js-priority-queue/js-priority-queue-tests.ts new file mode 100644 index 0000000000..e63cd0a8b8 --- /dev/null +++ b/js-priority-queue/js-priority-queue-tests.ts @@ -0,0 +1,26 @@ +/// + +import * as PriorityQueue from "js-priority-queue"; + +{ + var queue = new PriorityQueue({ comparator: (a, b) => b - a }); + queue.queue(5); + queue.queue(3); + queue.queue(2); + var lowest = queue.dequeue(); // returns 5 +} +{ + var compareNumbers = (a: number, b: number) => a - b; + new PriorityQueue({ comparator: compareNumbers }); +} +{ + new PriorityQueue({ initialValues: [1, 2, 3] }) +} +{ + new PriorityQueue({ strategy: PriorityQueue.ArrayStrategy }); // Array + new PriorityQueue({ strategy: PriorityQueue.BinaryHeapStrategy }); // Default + new PriorityQueue({ strategy: PriorityQueue.BHeapStrategy }); // Slower +} +{ + var a: PriorityQueue.PriorityQueueOptions; +} diff --git a/js-priority-queue/js-priority-queue.d.ts b/js-priority-queue/js-priority-queue.d.ts new file mode 100644 index 0000000000..dda0c47097 --- /dev/null +++ b/js-priority-queue/js-priority-queue.d.ts @@ -0,0 +1,64 @@ +// Type definitions for js-priority-queue +// Project: https://github.com/adamhooper/js-priority-queue +// Definitions by: York Yao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/* =================== USAGE =================== + import * as PriorityQueue from "js-priority-queue"; + var queue = new PriorityQueue({ comparator: (a, b) => b - a }); + queue.queue(5); + =============================================== */ + +declare module "js-priority-queue" { + class AbstractPriorityQueue { + /** + * Returns the number of elements in the queue + */ + public length: number; + /** + * Creates a priority queue + */ + constructor(options?: PriorityQueue.PriorityQueueOptions); + /** + * Inserts a new value in the queue + */ + public queue(value: T): void; + /** + * Returns the smallest item in the queue and leaves the queue unchanged + */ + public peek(): T; + /** + * Returns the smallest item in the queue and removes it from the queue + */ + public dequeue(): T; + /** + * Removes all values from the queue + */ + public clear(): void; + } + namespace PriorityQueue { + type PriorityQueueOptions = { + /** + * This is the argument we would pass to Array.prototype.sort + */ + comparator?: (a: T, b: T) => number; + /** + * You can also pass initial values, in any order. + * With lots of values, it's faster to load them all at once than one at a time. + */ + initialValues?: T[]; + /** + * According to JsPerf, the fastest strategy for most cases is BinaryHeapStrategy. + * Only use ArrayStrategy only if you're queuing items in a very particular order. + * Don't use BHeapStrategy, except as a lesson in how sometimes miracles in one programming language aren't great in other languages. + */ + strategy?: typeof AbstractPriorityQueue; + } + class ArrayStrategy extends AbstractPriorityQueue{ } + class BinaryHeapStrategy extends AbstractPriorityQueue{ } + class BHeapStrategy extends AbstractPriorityQueue{ } + + } + class PriorityQueue extends AbstractPriorityQueue { } + export = PriorityQueue; +} diff --git a/oracledb/oracledb-tests.ts b/oracledb/oracledb-tests.ts index d5b54a4976..3f9a0ddc5d 100644 --- a/oracledb/oracledb-tests.ts +++ b/oracledb/oracledb-tests.ts @@ -1,4 +1,3 @@ - /// import * as OracleDB from 'oracledb'; diff --git a/protobufjs/index.d.ts b/protobufjs/index.d.ts index bc3f43b902..6893936c85 100644 --- a/protobufjs/index.d.ts +++ b/protobufjs/index.d.ts @@ -164,7 +164,8 @@ declare namespace ProtoBuf { define(pkg: string, options?: {[key: string]: any}): ProtoBuilder; create(defs?: {[key: string]: any}[]): ProtoBuilder; resolveAll(): void; - build(path?: string): ProtoBuf; + build(path?: string | [string]): MetaMessage; + build(path?: string | [string]): MetaMessage; lookup(path?: string): ReflectT; } diff --git a/sanitize-html/index.d.ts b/sanitize-html/index.d.ts index a65f86c1b6..c5be474222 100644 --- a/sanitize-html/index.d.ts +++ b/sanitize-html/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for sanitize-html 1.12.0 +// Type definitions for sanitize-html 1.13.0 // Project: https://github.com/punkave/sanitize-html // Definitions by: Rogier Schouten , Afshin Darian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,46 +6,54 @@ export = sanitize; declare function sanitize(dirty: string, options?: sanitize.IOptions): string; + + declare namespace sanitize { - type Attributes = { [attr: string]: string }; + type Attributes = { [attr: string]: string }; - type Tag = { tagName: string; attributes: Attributes; }; + type Tag = { tagName: string; attribs: Attributes; text?: string; }; - type Transformer = (tagName: string, attributes: Attributes) => Tag; + type Transformer = (tagName: string, attribs: Attributes) => Tag; - interface IDefaults { - allowedAttributes: { [index: string]: string[] }; - allowedSchemes: string[]; - allowedSchemesByTag: { [index: string]: string[] }; - allowedTags: string[]; - selfClosing: string[]; - } + interface IDefaults { + allowedAttributes: { [index: string]: string[] }; + allowedSchemes: string[]; + allowedSchemesByTag: { [index: string]: string[] }; + allowedTags: string[]; + selfClosing: string[]; + } - interface IFrame { - tag: string; - attributes: { [index: string]: string }; - text: string; - tagPosition: number; - } + interface IFrame { + tag: string; + attribs: { [index: string]: string }; + text: string; + tagPosition: number; + } - interface IOptions { - allowedAttributes?: { [index: string]: string[] }; - allowedClasses?: { [index: string]: string[] }; - allowedSchemes?: string[]; - allowedTags?: string[]; - exclusiveFilter?: (frame: IFrame) => boolean; - selfClosing?: string[]; - transformTags?: { [tagName: string]: string | Transformer }; - } + interface IOptions { + allowedAttributes?: { [index: string]: string[] }; + allowedClasses?: { [index: string]: string[] }; + allowedSchemes?: string[]; + allowedTags?: string[]; + exclusiveFilter?: (frame: IFrame) => boolean; + nonTextTags?: string[]; + selfClosing?: string[]; + transformTags?: { [tagName: string]: string | Transformer }; + } - var defaults: IDefaults; + var defaults: IDefaults; - function simpleTransform(tagName: string, attributes: Attributes, merge?: boolean): Transformer; + function simpleTransform(tagName: string, attribs: Attributes, merge?: boolean): Transformer; +} + + +declare module 'sanitize-html' { + export = sanitize; } diff --git a/sanitize-html/sanitize-html-tests.ts b/sanitize-html/sanitize-html-tests.ts index fe367febf5..3774c7c1c7 100644 --- a/sanitize-html/sanitize-html-tests.ts +++ b/sanitize-html/sanitize-html-tests.ts @@ -9,11 +9,15 @@ let options: sanitize.IOptions = { }, transformTags: { 'a': sanitize.simpleTransform('a', { 'rel': 'nofollow' }), - 'img': 'canvas' - }, + 'img': (tagName: string, attribs: sanitize.Attributes) => { + let img = { tagName, attribs }; + img.attribs['alt'] = 'transformed' ; + return img; + } + }, exclusiveFilter: function(frame: sanitize.IFrame) { - return frame.tag === 'a' && !frame.text.trim(); - } + return frame.tag === 'a' && !frame.text.trim(); + } }; let unsafe = '
'; diff --git a/uuid/UUID-tests.ts b/uuid/UUID-tests.ts index 4feb0ce08a..2ba8fa57eb 100644 --- a/uuid/UUID-tests.ts +++ b/uuid/UUID-tests.ts @@ -1,4 +1,3 @@ - import UUID = require("uuid"); const uuid1: string = UUID.generate() diff --git a/vue-resource/index.d.ts b/vue-resource/index.d.ts index 735ec967bb..c886c5a449 100644 --- a/vue-resource/index.d.ts +++ b/vue-resource/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for vue-resoure 0.7.0 +// Type definitions for vue-resoure 0.9.3 // Project: https://github.com/vuejs/vue-resource // Definitions by: kaorun343 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,7 +15,7 @@ declare namespace vuejs { common?: { [key: string]: string }; custom?: { [key: string]: string }; [key: string]: any; - } + } interface HttpResponse { data: Object; @@ -23,21 +23,22 @@ declare namespace vuejs { status: number; statusText: string; headers: Function; + text():string; + json():string; + blob():string; } interface HttpOptions { url?: string; method?: string; - data?: any; + body?: any; params?: any; headers?: any; - beforeSend?(request: any): any; + before?(request: any): any; + progress?(event: any): any; + credentials?:boolean; emulateHTTP?: boolean; emulateJSON?: boolean; - xhr?: any; - upload?: any; - jsonp?: string; - timeout?: string; } interface $http { diff --git a/vue-resource/vue-resource-tests.ts b/vue-resource/vue-resource-tests.ts index 22cf64e74e..07baf8eaf6 100644 --- a/vue-resource/vue-resource-tests.ts +++ b/vue-resource/vue-resource-tests.ts @@ -29,6 +29,9 @@ class App extends Vue { response.headers('expires'); this.$set('someData', response.data); + this.$set('someJsonData', response.json()); + this.$set('someTextData', response.text()); + this.$set('someBlobData', response.blob()); }); var resource = this.$resource('someItem/{id}'); diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index f136606b87..e235c7920a 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -13,6 +13,19 @@ function test_HeadersCopiedFromHash() { return new Headers(source); } +function test_HeadersCopiedFromHeaders() { + var source = new Headers(); + source.append('Content-Type', 'application/json'); + return new Headers(source); +} + +function test_HeadersCopiedFromHash() { + var source:HeadersMap = { + 'Content-Type': 'application/json' + }; + return new Headers(source); +} + function test_fetchUrlWithOptions() { var headers = new Headers(); headers.append("Content-Type", "application/json"); From 33f79e40b1e1fab9dec053e735d93585b75effa1 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Sat, 30 Jul 2016 00:13:29 -0400 Subject: [PATCH 2/3] webcomponents.js: Add typings for Shadow DOM (#10345) --- webcomponents.js/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webcomponents.js/index.d.ts b/webcomponents.js/index.d.ts index 2f4ea424e4..6b658b6be9 100644 --- a/webcomponents.js/index.d.ts +++ b/webcomponents.js/index.d.ts @@ -33,7 +33,7 @@ declare namespace webcomponents { export interface ShadowRootPolyfill extends DocumentFragment { innerHTML: string; - host: Element; + readonly host: Element; } export interface Polyfill { @@ -48,7 +48,7 @@ declare module "webcomponents.js" { interface Element { createShadowRoot(): webcomponents.ShadowRootPolyfill; - shadowRoot?: webcomponents.ShadowRootPolyfill; + readonly shadowRoot?: webcomponents.ShadowRootPolyfill; } interface Document { From 2ef5e433457a5bf7366b06321548c61a6e41bb37 Mon Sep 17 00:00:00 2001 From: Yui Date: Sat, 30 Jul 2016 05:06:40 -0700 Subject: [PATCH 3/3] [Types-2.0] Merge master 07/29 round2 (#10372) * Including typings for globalize-compiler. * Updating typings for globalize-compiler to use the correct AST type. * Changed AtomicBlockUtils and KeyBindingUtil from interfaces to classes with static functions (#10324) * Fixing a few minor issues in webpack-stream. (#10253) * Document changes in 0.28 and 0.29 in React Native (#10309) * RN: Widen limit of refreshControl * RN: Update NavigationExperimental to 0.28 * RN: Define new method from 0.28 * RN: Promisify requestPermissions per 0.28 * RN: Remove onNavigate method See: https://github.com/facebook/react-native/commit/fb0007d85323909ab652bf97166744fa7e17daab#diff-04c37ff76f85aea35e8475617539b75fR94 * RN: Add onNavigateBack method See: https://github.com/facebook/react-native/commit/fb0007d85323909ab652bf97166744fa7e17daab#diff-04c37ff76f85aea35e8475617539b75fR94 * RN: Deprecate StatusBarIOS * RN: Update StyleSheet API per 0.29 * RN: Define KeyboardAvoidingView added in 0.29 * RN: Define saveToCameraRoll added in 0.29 * RN: Define cancellable from InteractionManager * RN: Add new possible values of flexDirection * RN: Define lineBreakMode * RN: Allow zIndex prop * RN: Allow dimension limits * RN: Specify type of refreshControl * RN: Mark properties as optional * RN: Clarify parameter naming * RN: Mark optional property as optional * RN: Definite explicit ref type * RN: Restore StyleSheet.create to restore compatibility * Added Headers constructor options to whatwg-fetch (#10313) * Impl: Updated definitions for oracledb (#10323) * Update select2 to have selectOnClose option (#10326) Option documented at https://select2.github.io/options.html#can-i-select-the-highlighted-result-when-the-dropdown-is-closed * Added definition for react-file-input React component (#10325) * Added definition for react-file-input React component * Added newline at end of file * Added definitions for the react-file-reader-input react component. (#10327) * Sleep (#10333) * Add Electron specific versions to process.versions (#10320) * Fix uuid.js definitions. (#10318) * protobufjs: updated Message interfaces (#10198) * protobufjs: updated Message interfaces * Added ProtoBuf.Util interface * Fixed load functions of ProtoBuf namespace Base on the protobuf.js API docmentation. * use {} instead of Object Fixed according to PR commit note. * Multiple minor fixes (#10339) * better typing of onShouldStartLoadWithRequest in WebViewPropertiesIOS * Fixes to WebViewProperties * Missing methods in Navigator * Fix of Platform.select() * added support for interfacing with native-modules * added support for interfacing with native-modules * added dev variable * Update to header notes * Examples: alternative styles declaration * webcomponents.js: Add typings for Element.createShadowRoot (#10330) * webcomponents.js: Add typings for Element.createShadowRoot createShadowRoot is deprecated in the official Shadow DOM spec, but is the way to attach a shadow root in the current released version of webcomponents.js. * webcomponents.js: remove spurious extra line * webcomponents.js: remove readonly modifier Not supported until TS2. * webcomponents.js: add Element.shadowRoot property * Adding a couple missing highcharts properites (#10340) * Adding a couple missing highcharts properites * Fixing indentation * Indentation * Update to Electron 1.3.1 (#10336) * Update to Electron 1.3.1 * Update editing command docs * Fix argument types * add definition of js-priority-queue (#10347) * Update to v1.13.0 and bug fix: sanitize-html expects tag attributes to be called attribs. (#10360) * updated vue-resource (#10349) * Updated to match docs for version 0.9.3 (latest as of 07/19/16) This is very important because response.data now returns raw data instead of a json object, you need to use res.json() to get an object representation of the response. .json() was missing from the typings. Aditionally modified a few breaking changes to match the documentation at: https://github.com/vuejs/vue-resource/blob/master/docs/http.md * Added tests for json, blob, and text * fixed version number * Added basic type definitions for react-relay (#10353) * Added basic type definitions for react-relay * Fixed tests * fix formatting * Fix application insights JS module initialization (#10364) * Added new type definition for gulp-help-doc (#10366) * Added gulp-help-doc definitions * Fixed declaration and tests * Fixed declaration and tests * Definition fixed * Declaration fixed * added LogisticRegressionClassifier definitions (#10307) * Add definitions for utf8 module (#10329) * added utf8 module typings added utf8 module typings * added tests for utf8 added tests for utf8 * moved import to es6 compatible moved import to es6 compatible * updated var to const updated var to const * removed interface and moved into module removed interface and moved into module * update const with let as it can be changed update const with let as it can be changed --- .../applicationinsights-js.d.ts | 2 +- electron/index.d.ts | 2 +- gulp-help-doc/gulp-help-doc-tests.ts | 27 +++++ gulp-help-doc/gulp-help-doc.d.ts | 56 +++++++++ react-relay/react-relay-test.tsx | 46 +++++++ react-relay/react-relay.d.ts | 112 ++++++++++++++++++ utf8/utf8-tests.ts | 19 +++ utf8/utf8.d.ts | 24 ++++ whatwg-fetch/whatwg-fetch-tests.ts | 13 ++ 9 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 gulp-help-doc/gulp-help-doc-tests.ts create mode 100644 gulp-help-doc/gulp-help-doc.d.ts create mode 100644 react-relay/react-relay-test.tsx create mode 100644 react-relay/react-relay.d.ts create mode 100644 utf8/utf8-tests.ts create mode 100644 utf8/utf8.d.ts diff --git a/applicationinsights-js/applicationinsights-js.d.ts b/applicationinsights-js/applicationinsights-js.d.ts index 9047f44b9f..ba154e5fe6 100644 --- a/applicationinsights-js/applicationinsights-js.d.ts +++ b/applicationinsights-js/applicationinsights-js.d.ts @@ -790,7 +790,7 @@ declare module Microsoft.ApplicationInsights { } declare module 'applicationinsights-js' { - export = appInsights; + export let AppInsights: Microsoft.ApplicationInsights.IAppInsights; } declare var appInsights: Microsoft.ApplicationInsights.IAppInsights; \ No newline at end of file diff --git a/electron/index.d.ts b/electron/index.d.ts index 36d580ccb4..4d6c993b1e 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v1.2.8 +// Type definitions for Electron v1.3.1 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/gulp-help-doc/gulp-help-doc-tests.ts b/gulp-help-doc/gulp-help-doc-tests.ts new file mode 100644 index 0000000000..f06c25e55c --- /dev/null +++ b/gulp-help-doc/gulp-help-doc-tests.ts @@ -0,0 +1,27 @@ +/// +/// +/// + +import gulp = require('gulp'); +import usage = require('gulp-help-doc'); + +/** + * Demo task + * + * @task {demo} + * @arg {env} environment + */ +gulp.task('demo', function() {}); + +let logger: { + output: string, + log(msg: string): any +} = { + output: '', + log: msg => logger.output += msg + '\n' +}; + +usage(gulp, { + logger: logger, + gulpfile: __filename +}).then(() => console.log(logger.output)); diff --git a/gulp-help-doc/gulp-help-doc.d.ts b/gulp-help-doc/gulp-help-doc.d.ts new file mode 100644 index 0000000000..80d4922774 --- /dev/null +++ b/gulp-help-doc/gulp-help-doc.d.ts @@ -0,0 +1,56 @@ +// Type definitions for gulp-help-doc +// Project: https://github.com/Mikhus/gulp-help-doc +// Definitions by: Mikhus +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "gulp-help-doc" { + + import gulp = require('gulp'); + + namespace usage { + + interface UsageOptions { + /** + * Defines max line width for the printed output lines + * (by default is 80 characters long) + */ + lineWidth?: number, + + /** + * Defines max width of the column width tasks or args names + * (by default is 20 characters long) + */ + keysColumnWidth?: number, + + /** + * Defines number of empty characters for left-padding of the output + */ + padding?: number, + + /** + * Printing engine (by default is console). Accepted any device + * which has log() function defined to do output. + */ + logger?: { log: Function }, + + /** + * Path to a gulpfile (default is gulpfile.js) + * Normally, there is no need to change this option. It may be used + * for some special cases, like mocking gulpfile for testing. + */ + gulpfile?: string + } + + interface Usage { + (gulp: gulp.Gulp, options?: UsageOptions): Promise + } + + } + + var usage: usage.Usage; + + export = usage; +} diff --git a/react-relay/react-relay-test.tsx b/react-relay/react-relay-test.tsx new file mode 100644 index 0000000000..e6632e76f9 --- /dev/null +++ b/react-relay/react-relay-test.tsx @@ -0,0 +1,46 @@ +/// +/// + +import * as React from "react" +import * as Relay from "react-relay" + +interface Props { + text: string + userId: string +} + +interface Response { +} + +export default class AddTweetMutation extends Relay.Mutation { + + getMutation () { + return Relay.QL`mutation{addTweet}` + } + + getFatQuery () { + return Relay.QL` + fragment on AddTweetPayload { + tweetEdge + user + } + ` + } + + getConfigs () { + return [{ + type: "RANGE_ADD", + parentName: "user", + parentID: this.props.userId, + connectionName: "tweets", + edgeName: "tweetEdge", + rangeBehaviors: { + "": "append", + }, + }] + } + + getVariables () { + return this.props + } +} diff --git a/react-relay/react-relay.d.ts b/react-relay/react-relay.d.ts new file mode 100644 index 0000000000..1a0ae89069 --- /dev/null +++ b/react-relay/react-relay.d.ts @@ -0,0 +1,112 @@ +// Type definitions for react-relay 0.9.2 +// Project: https://github.com/facebook/relay +// Definitions by: Johannes Schickling +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "react-relay" { + import * as React from "react"; + + /** Fragments are a hash of functions */ + interface Fragments { + [query: string]: ((variables?: RelayVariables) => string) + } + + interface CreateContainerOpts { + initialVariables?: Object + fragments: Fragments + prepareVariables?(prevVariables: RelayVariables): RelayVariables + } + + interface RelayVariables { + [name: string]: any + } + + /** add static getFragment method to the component constructor */ + interface RelayContainerClass extends React.ComponentClass { + getFragment: ((q: string) => string) + } + + interface RelayQueryRequestResolve { + response: any + } + + interface RelayMutationRequest { + getQueryString(): string + getVariables(): RelayVariables + resolve(result: RelayQueryRequestResolve): any + reject(errors: any): any + } + + interface RelayQueryRequest { + resolve(result: RelayQueryRequestResolve): any + reject(errors: any): any + + getQueryString(): string + getVariables(): RelayVariables + getID(): string + getDebugName(): string + } + + interface RelayNetworkLayer { + supports(...options: string[]): boolean + } + + class DefaultNetworkLayer implements RelayNetworkLayer { + constructor(host: string, options: any) + supports(...options: string[]): boolean + } + + function createContainer(component: React.ComponentClass, params?: CreateContainerOpts): RelayContainerClass + function injectNetworkLayer(networkLayer: RelayNetworkLayer): any + function isContainer(component: React.ComponentClass): boolean + function QL(...args: any[]): string + + class Route { + constructor(params?: RelayVariables) + } + + /** + * Relay Mutation class, where T are the props it takes and S is the returned payload from Relay.Store.update. + * S is typically dynamic as it depends on the data the app is currently using, but it's possible to always + * return some data in the payload using REQUIRED_CHILDREN which is where specifying S is the most useful. + */ + class Mutation { + props: T + + constructor(props: T) + static getFragment(q: string): string + } + + interface Transaction { + getError(): Error + Status(): number + } + + interface StoreUpdateCallbacks { + onFailure?(transaction: Transaction): any + onSuccess?(response: T): any + } + + interface Store { + commitUpdate(mutation: Mutation, callbacks?: StoreUpdateCallbacks): any + } + + var Store: Store + + class RootContainer extends React.Component {} + + interface RootContainerProps extends React.Props{ + Component: RelayContainerClass + route: Route + renderLoading?(): JSX.Element + renderFetched?(data: any): JSX.Element + renderFailure?(error: Error, retry: Function): JSX.Element + } + + interface RelayProp { + variables: any + setVariables(variables: Object): void + } +} diff --git a/utf8/utf8-tests.ts b/utf8/utf8-tests.ts new file mode 100644 index 0000000000..852311ea6c --- /dev/null +++ b/utf8/utf8-tests.ts @@ -0,0 +1,19 @@ +/// + +import * as utf8 from "utf8"; + +function test_encode(): void { + utf8.encode("\x49"); + utf8.encode("\uD800\uDC01"); +} + +function test_decode(): void { + utf8.decode("\xC2\x49"); + utf8.decode("\xF0\x90\x80\x81"); +} + +function test_version(): void { + if (typeof utf8.version === "string") { + console.log(utf8.version); + } +} diff --git a/utf8/utf8.d.ts b/utf8/utf8.d.ts new file mode 100644 index 0000000000..e9ee9d16b1 --- /dev/null +++ b/utf8/utf8.d.ts @@ -0,0 +1,24 @@ +// Type definitions for utf8 v2.1.1 +// Project: https://github.com/mathiasbynens/utf8.js +// Definitions by: Nick Zelei +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "utf8" { + /** + * A string representing the semantic version number. + */ + let version: string; + /** + * Encodes any given JavaScript string (string) as UTF-8, and returns the UTF-8-encoded version of the string. + * It throws an error if the input string contains a non-scalar value, i.e. a lone surrogate. + * @param {string} inputString + */ + function encode(inputString: string): string; + + /** + * Decodes any given UTF-8-encoded string (byteString) as UTF-8, and returns the UTF-8-decoded version of the string. + * It throws an error when malformed UTF-8 is detected. + * @param {string} byteString + */ + function decode(byteString: string): string; +} diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index e235c7920a..97141e0eef 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -26,6 +26,19 @@ function test_HeadersCopiedFromHash() { return new Headers(source); } +function test_HeadersCopiedFromHeaders() { + var source = new Headers(); + source.append('Content-Type', 'application/json'); + return new Headers(source); +} + +function test_HeadersCopiedFromHash() { + var source:HeadersMap = { + 'Content-Type': 'application/json' + }; + return new Headers(source); +} + function test_fetchUrlWithOptions() { var headers = new Headers(); headers.append("Content-Type", "application/json");