From eeff64b04e2b370baf7eeff55f1067dfca1edb11 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 4 May 2017 16:31:27 -0700 Subject: [PATCH 01/50] Update library files with children check --- types/react-router/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 07e22c26d5..81244caa29 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -83,7 +83,11 @@ export interface StaticRouterProps { } export class StaticRouter extends React.Component {} -export class Switch extends React.Component {} +export interface SwitchProps { + children?: JSX.Element | JSX.Element[]; + location?: H.Location; +} +export class Switch extends React.Component {} export interface match

{ params: P; From 65989c0d612eb630d8ebd71a3be432726e68ae38 Mon Sep 17 00:00:00 2001 From: ikokostya Date: Fri, 5 May 2017 03:44:11 +0300 Subject: [PATCH 02/50] @types/node: update dns.resolve* declarations (#16320) * @types/node: update dns.resolve* declarations Fixes: #11151 * review fixes --- types/node/index.d.ts | 100 +++++++++++++++++++++++++++++++-------- types/node/node-tests.ts | 39 +++++++++++++++ 2 files changed, 119 insertions(+), 20 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 7b81878fee..e778aad584 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1886,11 +1886,6 @@ declare module "url" { } declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } - // Supported getaddrinfo flags. export const ADDRCONFIG: number; export const V4MAPPED: number; @@ -1914,22 +1909,87 @@ declare module "dns" { family: number; } - export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; - export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; - export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; + export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; + export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[][]) => void): string[][]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + export interface ResolveOptions { + ttl: boolean; + } + + export interface ResolveWithTtlOptions extends ResolveOptions { + ttl: true; + } + + export interface RecordWithTtl { + address: string; + ttl: number; + } + + export interface MxRecord { + priority: number; + exchange: string; + } + + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + + export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void; + export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void; + + export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void; + export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void; + + export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException, addresses: RecordWithTtl[]) => void): void; + export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException, addresses: string[] | RecordWithTtl[]) => void): void; + + export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void; + export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + + export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; //Error codes diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 256d9a57b2..aeba9c7045 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -2179,6 +2179,45 @@ namespace dns_tests { const _addresses: string | dns.LookupAddress[] = addresses; const _family: number | undefined = family; }); + + dns.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "A", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "AAAA", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "MX", (err, addresses) => { + const _addresses: dns.MxRecord[] = addresses; + }); + + dns.resolve4("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve4("nodejs.org", {ttl: true}, (err, addresses) => { + const _addresses: dns.RecordWithTtl[] = addresses; + }); + { + const ttl = false; + dns.resolve4("nodejs.org", {ttl: ttl}, (err, addresses) => { + const _addresses: string[] | dns.RecordWithTtl[] = addresses; + }); + } + + dns.resolve6("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve6("nodejs.org", {ttl: true}, (err, addresses) => { + const _addresses: dns.RecordWithTtl[] = addresses; + }); + { + const ttl = false; + dns.resolve6("nodejs.org", {ttl: ttl}, (err, addresses) => { + const _addresses: string[] | dns.RecordWithTtl[] = addresses; + }); + } } /***************************************************************************** From 67b696444143b3a24a85544dbe5371ac593a51d1 Mon Sep 17 00:00:00 2001 From: Parambir Singh Date: Fri, 5 May 2017 10:44:38 +1000 Subject: [PATCH 03/50] Add a few missing type definitions for node.js zlib module (#16311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update index.d.ts Add overloaded methods for zlib module that take a ZlibOptions parameter along with a callback. * Add tests for new methods added to node’s zlib module definition. --- types/node/index.d.ts | 9 ++++++++- types/node/node-tests.ts | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index e778aad584..67f275c7b6 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Node.js v7.x // Project: http://nodejs.org/ -// Definitions by: Microsoft TypeScript , DefinitelyTyped +// Definitions by: Microsoft TypeScript , DefinitelyTyped , Parambir Singh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /************************************************ @@ -1091,18 +1091,25 @@ declare module "zlib" { export function createUnzip(options?: ZlibOptions): Unzip; export function deflate(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; + export function deflate(buf: Buffer | string, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function deflateSync(buf: Buffer | string, options?: ZlibOptions): Buffer; export function deflateRaw(buf: Buffer | string, callback: (error: Error, result: Buffer) => void): void; + export function deflateRaw(buf: Buffer | string, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function deflateRawSync(buf: Buffer | string, options?: ZlibOptions): Buffer; export function gzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function gzip(buf: Buffer, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function gzipSync(buf: Buffer, options?: ZlibOptions): Buffer; export function gunzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function gunzip(buf: Buffer, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer; export function inflate(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function inflate(buf: Buffer, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function inflateSync(buf: Buffer, options?: ZlibOptions): Buffer; export function inflateRaw(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function inflateRaw(buf: Buffer, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function inflateRawSync(buf: Buffer, options?: ZlibOptions): Buffer; export function unzip(buf: Buffer, callback: (error: Error, result: Buffer) => void): void; + export function unzip(buf: Buffer, options: ZlibOptions, callback: (error: Error, result: Buffer) => void): void; export function unzipSync(buf: Buffer, options?: ZlibOptions): Buffer; export namespace constants { diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index aeba9c7045..7cac17144e 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -534,19 +534,25 @@ const compressMe = new Buffer("some data"); const compressMeString = "compress me!"; zlib.deflate(compressMe, (err: Error, result: Buffer) => zlib.inflate(result, (err: Error, result: Buffer) => result)); +zlib.deflate(compressMe, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => zlib.inflate(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result)); zlib.deflate(compressMeString, (err: Error, result: Buffer) => zlib.inflate(result, (err: Error, result: Buffer) => result)); +zlib.deflate(compressMeString, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => zlib.inflate(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result)); const inflated = zlib.inflateSync(zlib.deflateSync(compressMe)); const inflatedString = zlib.inflateSync(zlib.deflateSync(compressMeString)); zlib.deflateRaw(compressMe, (err: Error, result: Buffer) => zlib.inflateRaw(result, (err: Error, result: Buffer) => result)); +zlib.deflateRaw(compressMe, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => zlib.inflateRaw(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result)); zlib.deflateRaw(compressMeString, (err: Error, result: Buffer) => zlib.inflateRaw(result, (err: Error, result: Buffer) => result)); +zlib.deflateRaw(compressMeString, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => zlib.inflateRaw(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result)); const inflatedRaw: Buffer = zlib.inflateRawSync(zlib.deflateRawSync(compressMe)); const inflatedRawString: Buffer = zlib.inflateRawSync(zlib.deflateRawSync(compressMeString)); zlib.gzip(compressMe, (err: Error, result: Buffer) => zlib.gunzip(result, (err: Error, result: Buffer) => result)); +zlib.gzip(compressMe, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => zlib.gunzip(result, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result)); const gunzipped: Buffer = zlib.gunzipSync(zlib.gzipSync(compressMe)); zlib.unzip(compressMe, (err: Error, result: Buffer) => result); +zlib.unzip(compressMe, { finishFlush: zlib.Z_SYNC_FLUSH }, (err: Error, result: Buffer) => result); const unzipped: Buffer = zlib.unzipSync(compressMe); // Simplified constructors From ca336951d08ff9d0ba80416514db39c045d4b55b Mon Sep 17 00:00:00 2001 From: robin labat Date: Fri, 5 May 2017 02:55:53 +0200 Subject: [PATCH 04/50] Correction of @types/js-schema for the import error: (#16090) 'Cannot invoke an expression whose type lacks a call signature. Type 'typeof 'js-schema'' has no compatible call signatures.' while importing with 'import * as schema from 'js-schema'' The previous import strategie ('import {default as schema} from 'js-schema') where raising an error after compilation. --- types/js-schema/index.d.ts | 30 ++++++++++++++---------------- types/js-schema/js-schema-tests.ts | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/types/js-schema/index.d.ts b/types/js-schema/index.d.ts index 8c332b8181..adccce7809 100644 --- a/types/js-schema/index.d.ts +++ b/types/js-schema/index.d.ts @@ -1,21 +1,23 @@ // Type definitions for js-schema // Project: https://github.com/molnarg/js-schema -// Definitions by: Marcin Porebski +// Definitions by: Marcin Porebski , Robin Labat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module 'js-schema' { - export interface Schema - { - (obj: any): boolean; // test obj against the schema + function schema(definition: any): schema.Schema; + + namespace schema { + interface Schema { + (obj: any): boolean; // test obj against the schema + } } - export default function schema(definition: any): Schema + export = schema; } -interface NumberConstructor -{ +interface NumberConstructor { min(n: number): NumberConstructor; max(n: number): NumberConstructor; below(n: number): NumberConstructor; @@ -23,28 +25,24 @@ interface NumberConstructor step(n: number): NumberConstructor; } -interface StringConstructor -{ +interface StringConstructor { of(charset: string): StringConstructor; of(length: number, charset: string): StringConstructor; of(minLength: number, maxLength: number, charset: string): StringConstructor; } -interface ArrayConstructor -{ +interface ArrayConstructor { like(arr: Array): ArrayConstructor; of(pattern: any): ArrayConstructor; of(length: number, pattern: any): ArrayConstructor; of(minLength: number, maxLength: number, pattern: any): ArrayConstructor; } -interface ObjectConstructor -{ +interface ObjectConstructor { like(obj: any): ObjectConstructor; reference(obj: any): ObjectConstructor; } -interface FunctionConstructor -{ +interface FunctionConstructor { reference(func: Function): FunctionConstructor; -} +} \ No newline at end of file diff --git a/types/js-schema/js-schema-tests.ts b/types/js-schema/js-schema-tests.ts index bb5098a434..028b860e0a 100644 --- a/types/js-schema/js-schema-tests.ts +++ b/types/js-schema/js-schema-tests.ts @@ -1,4 +1,4 @@ -import {default as schema} from 'js-schema'; +import * as schema from 'js-schema'; var Duck = schema({ // A duck swim : Function, // - can swim From e695fa67f67ed22ad896c9cf5ef35c49d0d85378 Mon Sep 17 00:00:00 2001 From: kwiateusz Date: Fri, 5 May 2017 02:56:16 +0200 Subject: [PATCH 05/50] Update definitions of owlcarousel (#16088) In lib responsiveBaseWidth is wrapped by JQuery --- types/owlcarousel/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/owlcarousel/index.d.ts b/types/owlcarousel/index.d.ts index f359e4012a..66242aa888 100644 --- a/types/owlcarousel/index.d.ts +++ b/types/owlcarousel/index.d.ts @@ -30,7 +30,7 @@ interface IOwlCarouselOptions { paginationNumbers?: boolean; responsive?: boolean; responsiveRefreshRate?: number; - responsiveBaseWidth?: JQuery; + responsiveBaseWidth?: JQuery | string; baseClass?: string; theme?: string; lazyLoad?: boolean; From c272249810a044318fbf98579fc28b1ba70d1a93 Mon Sep 17 00:00:00 2001 From: Youngrok Kim Date: Fri, 5 May 2017 09:56:40 +0900 Subject: [PATCH 06/50] Fix incorrect signature of createPath and createHref (#16063) (#16084) --- types/history/PathUtils.d.ts | 4 ++-- types/history/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/history/PathUtils.d.ts b/types/history/PathUtils.d.ts index 7ea7ed75a4..4cc947fcf3 100644 --- a/types/history/PathUtils.d.ts +++ b/types/history/PathUtils.d.ts @@ -1,7 +1,7 @@ -import { Path, Location, LocationDescriptor } from './index'; +import { Path, Location, LocationDescriptorObject } from './index'; export function addLeadingSlash(path: Path): Path; export function stripLeadingSlash(path: Path): Path; export function stripPrefix(path: Path, prefix: string): Path; export function parsePath(path: Path): Location; -export function createPath(location: LocationDescriptor): Path; +export function createPath(location: LocationDescriptorObject): Path; diff --git a/types/history/index.d.ts b/types/history/index.d.ts index a45b930efe..eda8c1bb10 100644 --- a/types/history/index.d.ts +++ b/types/history/index.d.ts @@ -20,7 +20,7 @@ export interface History { goForward(): void; block(prompt?: boolean): UnregisterCallback; listen(listener: LocationListener): UnregisterCallback; - createHref(location: Path | LocationDescriptorObject): Href; + createHref(location: LocationDescriptorObject): Href; } export interface Location { From 3426ce7a276dd7f4a35dce1f5ad65805b0b9e28b Mon Sep 17 00:00:00 2001 From: Ryan Riley Date: Thu, 4 May 2017 19:58:28 -0500 Subject: [PATCH 07/50] Add missing options and further refine parameter types for Handsontable 3.1.2 (#16078) * Add missing members and parameter types * Update original setDataAtCell overload * afterChange oldVal should be typed as any * Fix lint errors * Correctly type the prop value in the afterChange parameter --- types/handsontable/index.d.ts | 7 +++++-- types/handsontable/test/global.ts | 5 ++++- types/handsontable/test/module.ts | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/types/handsontable/index.d.ts b/types/handsontable/index.d.ts index 23f99e60a4..165d872e8f 100644 --- a/types/handsontable/index.d.ts +++ b/types/handsontable/index.d.ts @@ -79,7 +79,8 @@ declare namespace __Handsontable { selectCellByProp(row: number, prop: string, endRow?: number, endProp?: string, scrollToCell?: boolean): boolean; setCellMeta(row: number, col: number, key: string, val: string): void; setCellMetaObject(row: number, col: number, prop: Object): void; - setDataAtCell(row: number|any[], col: number, value: string, source?: string): void; + setDataAtCell(row: number, col: number, value: string, source?: string): void; + setDataAtCell(changes: Array<[number, number, any]>): void; setDataAtRowProp(row: number|any[], prop: string, value: string, source?: string): void; spliceCol(col: number, index: number, amount: number, elements?: any): void; spliceRow(row: number, index: number, amount: number, elements?: any): void; @@ -218,7 +219,7 @@ declare namespace Handsontable { // hooks afterAutofillApplyValues?(startArea: any[], entireArea: any[]): void; afterCellMetaReset?(): void; - afterChange?(changes: any[], source: string): void; + afterChange?(changes: Array<[number, number|string, any, any]>, source?: string): void; afterChangesObserved?(): void; afterColumnMove?(startColumn: number, endColumn: number): void; afterColumnResize?(currentColumn: number, newSize: number, isDoubleClick: boolean): void; @@ -241,6 +242,7 @@ declare namespace Handsontable { afterInit?(): void; afterLoadData?(firstTime: boolean): void; afterMomentumScroll?(): void; + afterOnCellCornerDblClick?(event: Object): void; afterOnCellCornerMouseDown?(event: Object): void; afterOnCellMouseDown?(event: Object, coords: Object, TD: Element): void; afterOnCellMouseOver?(event: Object, coords: Object, TD: Element): void; @@ -412,6 +414,7 @@ declare namespace Handsontable { getWindowScrollTop(): number; outerHeight(element: HTMLElement): number; hasClass(element: HTMLElement, className: string): boolean | undefined; + empty(element: HTMLElement): void; } interface ArrayMapper { diff --git a/types/handsontable/test/global.ts b/types/handsontable/test/global.ts index d4516d80e1..331f62759d 100644 --- a/types/handsontable/test/global.ts +++ b/types/handsontable/test/global.ts @@ -122,7 +122,7 @@ function test_HandsontableInit() { // Hooks afterAutofillApplyValues: () => {return; }, afterCellMetaReset: () => {return; }, - afterChange: () => {return; }, + afterChange: (changes) => {return; }, afterChangesObserved: () => {return; }, afterColumnMove: () => {return; }, afterColumnResize: () => {return; }, @@ -145,6 +145,7 @@ function test_HandsontableInit() { afterInit: () => {return; }, afterLoadData: () => {return; }, afterMomentumScroll: () => {return; }, + afterOnCellCornerDblClick: () => {return; }, afterOnCellCornerMouseDown: () => {return; }, afterOnCellMouseDown: () => {return; }, afterOnCellMouseOver: () => {return; }, @@ -276,6 +277,7 @@ function test_HandsontableMethods() { hot.setCellMeta(123, 123, 'foo', 'foo'); hot.setCellMetaObject(123, 123, {}); hot.setDataAtCell(123, 123, 'foo', 'foo'); + hot.setDataAtCell([[123, 123, 'foo'], [123, 123, 'foo']]); hot.setDataAtRowProp(123, 'foo', 'foo', 'foo'); hot.spliceCol(123, 123, 123, 'foo'); hot.spliceRow(123, 123, 123, 'foo'); @@ -290,6 +292,7 @@ function test_HandsontableMethods() { Handsontable.renderers.NumericRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {}); Handsontable.renderers.TextRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {}); Handsontable.Dom.addEvent(new HTMLElement(), "eventName", () => { return; }); + Handsontable.Dom.empty(new HTMLElement()); } class MyCustomHotPlugin extends Handsontable.plugins.BasePlugin { diff --git a/types/handsontable/test/module.ts b/types/handsontable/test/module.ts index 5d0ef22655..a67ab6942d 100644 --- a/types/handsontable/test/module.ts +++ b/types/handsontable/test/module.ts @@ -124,7 +124,7 @@ function test_HandsontableInit() { // Hooks afterAutofillApplyValues: () => {return; }, afterCellMetaReset: () => {return; }, - afterChange: () => {return; }, + afterChange: (changes) => {return; }, afterChangesObserved: () => {return; }, afterColumnMove: () => {return; }, afterColumnResize: () => {return; }, @@ -147,6 +147,7 @@ function test_HandsontableInit() { afterInit: () => {return; }, afterLoadData: () => {return; }, afterMomentumScroll: () => {return; }, + afterOnCellCornerDblClick: () => {return; }, afterOnCellCornerMouseDown: () => {return; }, afterOnCellMouseDown: () => {return; }, afterOnCellMouseOver: () => {return; }, @@ -278,6 +279,7 @@ function test_HandsontableMethods() { hot.setCellMeta(123, 123, 'foo', 'foo'); hot.setCellMetaObject(123, 123, {}); hot.setDataAtCell(123, 123, 'foo', 'foo'); + hot.setDataAtCell([[123, 123, 'foo'], [123, 123, 'foo']]); hot.setDataAtRowProp(123, 'foo', 'foo', 'foo'); hot.spliceCol(123, 123, 123, 'foo'); hot.spliceRow(123, 123, 123, 'foo'); @@ -292,6 +294,7 @@ function test_HandsontableMethods() { Handsontable.renderers.NumericRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {}); Handsontable.renderers.TextRenderer(hot, new HTMLTableDataCellElement(), 0, 0, "prop", 1.235, {}); Handsontable.Dom.addEvent(new HTMLElement(), "eventName", () => { return; }); + Handsontable.Dom.empty(new HTMLElement()); } class MyCustomHotPlugin extends Handsontable.plugins.BasePlugin { From 34d30931f073be30b5333de2e1afd5aa43440d6d Mon Sep 17 00:00:00 2001 From: Nicolas Voigt Date: Fri, 5 May 2017 03:01:24 +0200 Subject: [PATCH 08/50] Updated bonjour types (were not working on typescript 2.2) (#16075) * new typings * updated types into a namespace to allow the default function to be fired * typo on findOne * DT tests passed --- types/bonjour/bonjour-tests.ts | 25 +++--- types/bonjour/index.d.ts | 142 ++++++++++++++++++--------------- types/bonjour/tslint.json | 6 ++ 3 files changed, 98 insertions(+), 75 deletions(-) create mode 100644 types/bonjour/tslint.json diff --git a/types/bonjour/bonjour-tests.ts b/types/bonjour/bonjour-tests.ts index 1ae8a218fe..61e7373f01 100644 --- a/types/bonjour/bonjour-tests.ts +++ b/types/bonjour/bonjour-tests.ts @@ -1,20 +1,23 @@ import * as bonjour from 'bonjour'; -var bonjourOptions: bonjour.BonjourOptions; -var bonjourInstance: bonjour.Bonjour; +let bonjourOptions: bonjour.BonjourOptions; +let bonjourInstance: bonjour.Bonjour; -var serviceOptions: bonjour.ServiceOptions; -var service: bonjour.Service; +let serviceOptions: bonjour.ServiceOptions; +let service: bonjour.Service; -var browserOptions: bonjour.BrowserOptions; -var browser: bonjour.Browser; +let browserOptions: bonjour.BrowserOptions; +let browser: bonjour.Browser; -bonjourOptions = { interface: '192.168.1.1', port: 5353 }; -bonjourInstance = new bonjour.Bonjour(bonjourOptions); +bonjourOptions = {}; +bonjourInstance = bonjour(bonjourOptions); -serviceOptions = { name: 'My Web Server', type: 'http', port: 3000 }; +// Publish a dummy server under name 'My Website' type http port 3000 +serviceOptions = { name: 'My Website', type: 'http', port: 3000 }; service = bonjourInstance.publish(serviceOptions); browserOptions = { protocol: 'tcp', type: 'http' }; -browser = bonjour.find(browserOptions); - +// Look for the server +browser = bonjourInstance.findOne(browserOptions, (srv: bonjour.Service) => { + // You can test here if the found server (srv) name is 'My Website' +}); diff --git a/types/bonjour/index.d.ts b/types/bonjour/index.d.ts index 0eb5b584c0..bba5debb3c 100644 --- a/types/bonjour/index.d.ts +++ b/types/bonjour/index.d.ts @@ -1,68 +1,82 @@ -// Type definitions for bonjour v3.5.0 +// Type definitions for bonjour 3.5 // Project: https://github.com/watson/bonjour -// Definitions by: Quentin Lampin +// Definitions by: Quentin Lampin , Nicolas Voigt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// -export interface BonjourOptions { - multicast?: boolean; - interface?: string; - port?: number; - ip?: string; - ttl?: number; - loopback?: boolean; - reuseAddr?: boolean; +declare function bonjour(opts?: bonjour.BonjourOptions): bonjour.Bonjour; +export = bonjour; +declare namespace bonjour { + /** + * Start a browser + * + * The browser listens for services by querying for PTR records of a given + * type, protocol and domain, e.g. _http._tcp.local. + * + * If no type is given, a wild card search is performed. + * + * An internal list of online services is kept which starts out empty. When + * ever a new service is discovered, it's added to the list and an "up" event + * is emitted with that service. When it's discovered that the service is no + * longer available, it is removed from the list and a "down" event is emitted + * with that service. + */ + interface Browser extends NodeJS.EventEmitter { + services: Service[]; + start(): void; + update(): void; + stop(): void; + on(event: 'up' | 'down', listener: (service: Service) => void): this; + once(event: 'up' | 'down', listener: (service: Service) => void): this; + removeListener(event: 'up' | 'down', listener: (service: Service) => void): this; + removeAllListeners(event: 'up' | 'down'): this; + } + interface BrowserOptions { + type?: string; + subtypes?: string[]; + protocol?: string; + txt?: Object; + } + + interface ServiceOptions { + name: string; + host?: string; + port: number; + type: string; + subtypes?: string[]; + protocol?: 'udp'|'tcp'; + txt?: Object; + } + + interface Service extends NodeJS.EventEmitter { + name: string; + type: string; + subtypes: string[]; + protocol: string; + host: string; + port: number; + fqdn: string; + txt: Object; + published: boolean; + + stop(cb: () => any): void; + start(): void; + } + interface BonjourOptions { + multicast?: boolean; + interface?: string; + port?: number; + ip?: string; + ttl?: number; + loopback?: boolean; + reuseAddr?: boolean; + } + interface Bonjour { + (opts?: BonjourOptions): Bonjour; + publish(options: ServiceOptions): Service; + unpublishAll(cb?: () => void): void; + find(options: BrowserOptions, onUp?: (service: Service) => void): Browser; + findOne(options: BrowserOptions, cb?: (service: Service) => void): Browser; + destroy(): void; + } } - -export interface BrowserOptions { - type?: string; - subtypes?: string[]; - protocol?: string; - txt?: Object; -} - -export interface ServiceOptions { - name: string; - host?: string; - port: number; - type: string; - subtypes?: string[]; - protocol?: 'udp'|'tcp'; - txt?: Object; -} - -export interface Service { - name: string; - type: string; - subtypes: string[]; - protocol: string; - host: string; - port: number; - fqdn: string; - rawTxt: Object; - txt: Object; - published: boolean; - - stop: (cb: ()=>any) => void; - start: () => void; -} - -export class Bonjour { - - constructor(opts: BonjourOptions); - publish(options: ServiceOptions):Service; - unpublishAll(cb: ()=>any): void; - find(options:BrowserOptions, onUp: ()=>any): Browser; - findOne(options:any, cb: (service: Service)=>any): Browser; - destroy():void; -} - -export class Browser { - services: Service[]; - - start():void; - update():void; - stop():void; -} - -export function find(options: BrowserOptions, onUp?: ()=>any): Browser; -export function findOne(options: BrowserOptions): Browser; diff --git a/types/bonjour/tslint.json b/types/bonjour/tslint.json new file mode 100644 index 0000000000..a62d0d4e68 --- /dev/null +++ b/types/bonjour/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "ban-types": false + } +} From 9fbba5a517a15a75ba086ee796635efd9977a4e5 Mon Sep 17 00:00:00 2001 From: Lucas Neiva Date: Fri, 5 May 2017 03:01:48 +0200 Subject: [PATCH 09/50] Add babel-types NullLiteral type aliases (#16066) --- types/babel-types/babel-types-tests.ts | 2 ++ types/babel-types/index.d.ts | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/types/babel-types/babel-types-tests.ts b/types/babel-types/babel-types-tests.ts index cb02d11ee1..7b82dfc675 100644 --- a/types/babel-types/babel-types-tests.ts +++ b/types/babel-types/babel-types-tests.ts @@ -24,3 +24,5 @@ if (t.isBinaryExpression(ast)) { } t.assertBinaryExpression(ast); t.assertBinaryExpression(ast, { operator: "*" }); + +var exp: t.Expression = t.nullLiteral(); diff --git a/types/babel-types/index.d.ts b/types/babel-types/index.d.ts index b3b0f966c6..495b818a0b 100644 --- a/types/babel-types/index.d.ts +++ b/types/babel-types/index.d.ts @@ -870,7 +870,7 @@ export interface SpreadProperty extends Node { argument: Expression; } -export type Expression = ArrayExpression | AssignmentExpression | BinaryExpression | CallExpression | ConditionalExpression | FunctionExpression | Identifier | StringLiteral | NumericLiteral | BooleanLiteral | RegExpLiteral | LogicalExpression | MemberExpression | NewExpression | ObjectExpression | SequenceExpression | ThisExpression | UnaryExpression | UpdateExpression | ArrowFunctionExpression | ClassExpression | MetaProperty | Super | TaggedTemplateExpression | TemplateLiteral | YieldExpression | TypeCastExpression | JSXElement | JSXEmptyExpression | JSXIdentifier | JSXMemberExpression | ParenthesizedExpression | AwaitExpression | BindExpression | DoExpression; +export type Expression = ArrayExpression | AssignmentExpression | BinaryExpression | CallExpression | ConditionalExpression | FunctionExpression | Identifier | StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | RegExpLiteral | LogicalExpression | MemberExpression | NewExpression | ObjectExpression | SequenceExpression | ThisExpression | UnaryExpression | UpdateExpression | ArrowFunctionExpression | ClassExpression | MetaProperty | Super | TaggedTemplateExpression | TemplateLiteral | YieldExpression | TypeCastExpression | JSXElement | JSXEmptyExpression | JSXIdentifier | JSXMemberExpression | ParenthesizedExpression | AwaitExpression | BindExpression | DoExpression; export type Binary = BinaryExpression | LogicalExpression; export type Scopable = BlockStatement | CatchClause | DoWhileStatement | ForInStatement | ForStatement | FunctionDeclaration | FunctionExpression | Program | ObjectMethod | SwitchStatement | WhileStatement | ArrowFunctionExpression | ClassDeclaration | ClassExpression | ForOfStatement | ClassMethod; export type BlockParent = BlockStatement | DoWhileStatement | ForInStatement | ForStatement | FunctionDeclaration | FunctionExpression | Program | ObjectMethod | SwitchStatement | WhileStatement | ArrowFunctionExpression | ForOfStatement | ClassMethod; @@ -886,11 +886,11 @@ export type For = ForInStatement | ForStatement | ForOfStatement; export type ForXStatement = ForInStatement | ForOfStatement; export type Function = FunctionDeclaration | FunctionExpression | ObjectMethod | ArrowFunctionExpression | ClassMethod; export type FunctionParent = FunctionDeclaration | FunctionExpression | Program | ObjectMethod | ArrowFunctionExpression | ClassMethod; -export type Pureish = FunctionDeclaration | FunctionExpression | StringLiteral | NumericLiteral | BooleanLiteral | ArrowFunctionExpression | ClassDeclaration | ClassExpression; +export type Pureish = FunctionDeclaration | FunctionExpression | StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | ArrowFunctionExpression | ClassDeclaration | ClassExpression; export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | DeclareClass | DeclareFunction | DeclareInterface | DeclareModule | DeclareTypeAlias | DeclareVariable | InterfaceDeclaration | TypeAlias; export type LVal = Identifier | MemberExpression | RestElement | AssignmentPattern | ArrayPattern | ObjectPattern; -export type Literal = StringLiteral | NumericLiteral | BooleanLiteral | RegExpLiteral | TemplateLiteral; -export type Immutable = StringLiteral | NumericLiteral | BooleanLiteral | JSXAttribute | JSXClosingElement | JSXElement | JSXExpressionContainer | JSXOpeningElement; +export type Literal = StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | RegExpLiteral | TemplateLiteral; +export type Immutable = StringLiteral | NumericLiteral | BooleanLiteral | NullLiteral | JSXAttribute | JSXClosingElement | JSXElement | JSXExpressionContainer | JSXOpeningElement; export type UserWhitespacable = ObjectMethod | ObjectProperty | ObjectTypeCallProperty | ObjectTypeIndexer | ObjectTypeProperty; export type Method = ObjectMethod | ClassMethod; export type ObjectMember = ObjectMethod | ObjectProperty; From 39cf359166731430683db943d8043ce6dba0160e Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Fri, 5 May 2017 04:04:37 +0300 Subject: [PATCH 10/50] Recreated types for flux@3.2 (#15800) * Recreated types for flux@3.1.2. * Added backward compatibility with implementation. Added overload for create method. * Fixed tslint error in tests. * Added one more test for old implementation. * Added more gerenrics in create method. Updated tests. * Fixed errors. * Typescript version changed to 2.2. * Updated `createFunctional` return. --- types/flux/flux-tests.ts | 126 ------------------------- types/flux/index.d.ts | 73 ++------------- types/flux/lib/Dispatcher.d.ts | 45 +++++++++ types/flux/lib/FluxContainer.d.ts | 65 +++++++++++++ types/flux/lib/FluxMixinLegacy.d.ts | 26 ++++++ types/flux/lib/FluxReduceStore.d.ts | 36 +++++++ types/flux/lib/FluxStore.d.ts | 74 +++++++++++++++ types/flux/test/Flux.ts | 71 ++++++++++++++ types/flux/test/FluxUtils.tsx | 80 ++++++++++++++++ types/flux/tsconfig.json | 21 +++-- types/flux/tslint.json | 3 + types/flux/utils.d.ts | 11 +++ types/flux/utils/index.d.ts | 140 ---------------------------- 13 files changed, 433 insertions(+), 338 deletions(-) delete mode 100644 types/flux/flux-tests.ts create mode 100644 types/flux/lib/Dispatcher.d.ts create mode 100644 types/flux/lib/FluxContainer.d.ts create mode 100644 types/flux/lib/FluxMixinLegacy.d.ts create mode 100644 types/flux/lib/FluxReduceStore.d.ts create mode 100644 types/flux/lib/FluxStore.d.ts create mode 100644 types/flux/test/Flux.ts create mode 100644 types/flux/test/FluxUtils.tsx create mode 100644 types/flux/tslint.json create mode 100644 types/flux/utils.d.ts delete mode 100644 types/flux/utils/index.d.ts diff --git a/types/flux/flux-tests.ts b/types/flux/flux-tests.ts deleted file mode 100644 index 57c8fb3b20..0000000000 --- a/types/flux/flux-tests.ts +++ /dev/null @@ -1,126 +0,0 @@ -import flux = require('flux') -import FluxUtils = require('flux/utils') -import React = require('react') - -var Component = React.Component -var Container = FluxUtils.Container - -// -// Basic dispatcher usage -// - -var basicDispatcher = new flux.Dispatcher() - -// register(callback: (payload: any) => void): string -var id: string = basicDispatcher.register((payload) => { - // payload is type: any - payload.anything -}) - -// unregister(id: string): void -basicDispatcher.unregister(id) - -// waitFor(ids: string[]): void -basicDispatcher.waitFor([id]) - -// dispatch(payload: any): void -basicDispatcher.dispatch({ msg: 'hello' }) - -// isDispatching(): boolean -var dispatcherIsDispatching: boolean = basicDispatcher.isDispatching() - -// -// Typed payload -// - -enum ActionSource { Server, View } -enum ActionType { Create, Update, Delete } - -interface Action { - source: ActionSource - type: ActionType - data: Object -} - -var typedDispatcher = new flux.Dispatcher() - -var typedPayload: Action - -var typedStore = { - dispatcherID: typedDispatcher.register((payload) => { - typedPayload = payload - }) -} - -typedDispatcher.dispatch(typedPayload) - -// -// Derived dispatcher -// - -class CustomDispatcher extends flux.Dispatcher { - - // Dispatch an action with server as source - handleServerAction(type: ActionType, data: Object) { - this.dispatch({ - source: ActionSource.Server, - type: type, - data: data, - }) - } - - // Dispatch an action with view as source - handleViewAction(type: ActionType, data: Object) { - this.dispatch({ - source: ActionSource.View, - type: type, - data: data, - }) - } -} - -var customDispatcher = new CustomDispatcher() - -export = customDispatcher - - -// Sample Reduce Store -class CounterStore extends FluxUtils.ReduceStore { - getInitialState(): number { - return 0; - } - - reduce(state: number, action: any): number { - switch (action.type) { - case 'increment': - return state + 1; - - case 'square': - return state * state; - - default: - return state; - } - } -} - -const Store = new CounterStore(basicDispatcher); - -// Sample Flux container with CounterStore -class CounterContainer extends Component { - static getStores() { - return [Store]; - } - - static calculateState(prevState: any) { - return { - counter: Store.getState(), - }; - } - - render() { - return this.state.counter; - } -} - -const container = Container.create(CounterContainer); diff --git a/types/flux/index.d.ts b/types/flux/index.d.ts index 54fecd3a4e..7380613ce7 100644 --- a/types/flux/index.d.ts +++ b/types/flux/index.d.ts @@ -1,69 +1,12 @@ -// Type definitions for Flux 3.0 +// Type definitions for Flux 3.1 // Project: http://facebook.github.io/flux/ -// Definitions by: Steve Baker , Giedrius Grabauskas +// Definitions by: Steve Baker +// Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 -/// -/// +import * as Dispatcher from "./lib/Dispatcher"; -export = Flux; - -declare namespace Flux { - - /** - * Dispatcher class - * Create an instance to use throughout the application. - * Or extend it to create a derived dispatcher class. - * - * Specify a type in the 'TPayload' generic argument to use strongly-typed payloads, - * otherwise specify 'any' - * - * Examples: - * var dispatcher = new flux.Dispatcher() - * var typedDispatcher = new flux.Dispatcher() - * class DerivedDispatcher extends flux.Dispatcher { } - */ - export class Dispatcher { - - /** - * Create an instance of the Dispatcher class to use throughout the application. - * - * Specify a type in the 'TPayload' generic argument to use strongly-typed payloads, - * otherwise specify 'any' - * - * Examples: - * var dispatcher = new flux.Dispatcher() - * var typedDispatcher = new flux.Dispatcher() - */ - constructor(); - - /** - * Registers a callback that will be invoked with every payload sent to the dispatcher. - * Returns a string token to identify the callback to be used with waitFor() or unregister. - */ - register(callback: (payload: TPayload) => void): string; - - /** - * Unregisters a callback with the given ID token - */ - unregister(id: string): void; - - /** - * Waits for the callbacks with the specified IDs to be invoked before continuing execution - * of the current callback. This method should only be used by a callback in response - * to a dispatched payload. - */ - waitFor(IDs: string[]): void; - - /** - * Dispatches a payload to all registered callbacks - */ - dispatch(payload: TPayload): void; - - /** - * Gets whether the dispatcher is currently dispatching - */ - isDispatching(): boolean; - } -} +export { + Dispatcher +}; diff --git a/types/flux/lib/Dispatcher.d.ts b/types/flux/lib/Dispatcher.d.ts new file mode 100644 index 0000000000..045d633088 --- /dev/null +++ b/types/flux/lib/Dispatcher.d.ts @@ -0,0 +1,45 @@ +declare namespace Dispatcher { } + +declare class Dispatcher { + /** + * Create an instance of the Dispatcher class to use throughout the application. + * + * Specify a type in the 'TPayload' generic argument to use strongly-typed payloads, + * otherwise specify 'any' + * + * Examples: + * var dispatcher = new flux.Dispatcher() + * var typedDispatcher = new flux.Dispatcher() + */ + constructor(); + + /** + * Registers a callback that will be invoked with every payload sent to the dispatcher. + * Returns a string token to identify the callback to be used with waitFor() or unregister. + */ + register(callback: (payload: TPayload) => void): string; + + /** + * Unregisters a callback with the given ID token + */ + unregister(id: string): void; + + /** + * Waits for the callbacks with the specified IDs to be invoked before continuing execution + * of the current callback. This method should only be used by a callback in response + * to a dispatched payload. + */ + waitFor(IDs: string[]): void; + + /** + * Dispatches a payload to all registered callbacks + */ + dispatch(payload: TPayload): void; + + /** + * Gets whether the dispatcher is currently dispatching + */ + isDispatching(): boolean; +} + +export = Dispatcher; diff --git a/types/flux/lib/FluxContainer.d.ts b/types/flux/lib/FluxContainer.d.ts new file mode 100644 index 0000000000..54b578cc1d --- /dev/null +++ b/types/flux/lib/FluxContainer.d.ts @@ -0,0 +1,65 @@ +import * as Dispatcher from "./Dispatcher"; +import * as FluxStore from "./FluxStore"; +import * as React from "react"; + +/** + * A FluxContainer is used to subscribe a react component to multiple stores. + * The stores that are used must be returned from a static `getStores()` method. + * + * The component receives information from the stores via state. The state + * is generated using a static `calculateState()` method that each container must implement. + */ +/** + * Default options to create a Container. + * + * @interface RealOptions + */ +export interface RealOptions { + /** + * Default value: true + * + * @type {boolean} + */ + pure?: boolean; + /** + * Default value: false + * + * @type {boolean} + */ + withProps?: boolean; + /** + * Default value: false + * + * @type {boolean} + */ + withContext?: boolean; +} + +export type ComponentConstructor = React.ComponentClass | React.StatelessComponent; + +export interface ComponentStatic { + getStores(maybeProps?: TProps, maybeContext?: TContext): Array>; + calculateState(prevState: TState, maybeProps?: TProps, maybeContext?: TContext): TState; +} + +export type Component = ComponentConstructor & ComponentStatic; + +/** + * Create is used to transform a react class into a container + * that updates its state when relevant stores change. + * The provided base class must have static methods getStores() and calculateState(). + */ +export function create(base: Component, options?: RealOptions): Component; +export function create(base: Component, options?: RealOptions): Component; +export function create(base: Component, options?: RealOptions): Component; +export function create(base: Component & TStatic, options?: RealOptions): Component & TStatic; + +/** + * This is a way to connect stores to a functional stateless view. + */ +export function createFunctional( + viewFn: (props: TProps) => React.ReactElement, + getStores: (maybeProps?: TProps, maybeContext?: any) => Array>, + calculateState: (prevState?: TState, maybeProps?: TProps, maybeContext?: any) => TState, + options?: RealOptions +): Component; diff --git a/types/flux/lib/FluxMixinLegacy.d.ts b/types/flux/lib/FluxMixinLegacy.d.ts new file mode 100644 index 0000000000..2ce825e3da --- /dev/null +++ b/types/flux/lib/FluxMixinLegacy.d.ts @@ -0,0 +1,26 @@ +import * as FluxStore from "./FluxStore"; + +declare namespace FluxMixinLegacy { + interface Options { + withProps?: boolean; + } +} + +/** + * `FluxContainer` should be preferred over this mixin, but it requires using + * react with classes. So this mixin is provided where it is not yet possible + * to convert a container to be a class. + * + * This mixin should be used for React components that have state based purely + * on stores. `this.props` will not be available inside of `calculateState()`. + * + * This mixin will only `setState` not replace it, so you should always return + * every key in your state unless you know what you are doing. + * + * On the second calculateState when prevState is not null, the state will be + * updated to contain the previous foo AND the bar that was just returned. Only + * returning bar will not delete foo. + */ +declare function FluxMixinLegacy(stores: Array>, options?: FluxMixinLegacy.Options): any; + +export = FluxMixinLegacy; diff --git a/types/flux/lib/FluxReduceStore.d.ts b/types/flux/lib/FluxReduceStore.d.ts new file mode 100644 index 0000000000..71a7968812 --- /dev/null +++ b/types/flux/lib/FluxReduceStore.d.ts @@ -0,0 +1,36 @@ +import * as Store from "./FluxStore"; + +declare namespace FluxReduceStore { } + +/** + * This is the basic building block of a Flux application. All of your stores + * should extend this class. + */ +declare abstract class FluxReduceStore extends Store { + /** + * Getter that exposes the entire state of this store. + * If your state is not immutable you should override this and not expose state directly. + */ + getState(): TState; + + /** + * Constructs the initial state for this store. + * This is called once during construction of the store. + */ + abstract getInitialState(): TState; + + /** + * Reduces the current state, and an action to the new state of this store. + * All subclasses must implement this method. + * This method should be pure and have no side-effects. + */ + abstract reduce(state: TState, action: TPayload): TState; + + /** + * Checks if two versions of state are the same. + * You do not need to override this if your state is immutable. + */ + areEqual(one: TState, two: TState): boolean; +} + +export = FluxReduceStore; diff --git a/types/flux/lib/FluxStore.d.ts b/types/flux/lib/FluxStore.d.ts new file mode 100644 index 0000000000..a0b2384c72 --- /dev/null +++ b/types/flux/lib/FluxStore.d.ts @@ -0,0 +1,74 @@ +import * as Dispatcher from "./Dispatcher"; +import * as fbEmitter from "fbemitter"; + +declare namespace FluxStore { } + +/** + * This class represents the most basic functionality for a FluxStore. Do not + * extend this store directly; instead extend FluxReduceStore when creating a + * new store. + */ +declare abstract class FluxStore { + /** + * Constructs and registers an instance of this store with the given dispatcher. + */ + constructor(dispatcher: Dispatcher); + + /** + * Adds a listener to the store, when the store changes the given callback will be called. + * A token is returned that can be used to remove the listener. + * Calling the remove() function on the returned token will remove the listener. + */ + addListener(callback: () => void): fbEmitter.EventSubscription; + + /** + * Returns the dispatcher this store is registered with. + */ + getDispatcher(): Dispatcher; + + /** + * Returns the dispatch token that the dispatcher recognizes this store by. + * Can be used to waitFor() this store. + */ + getDispatchToken(): string; + + /** + * Ask if a store has changed during the current dispatch. + * Can only be invoked while dispatching. + * This can be used for constructing derived stores that depend on data from other stores. + */ + hasChanged(): boolean; + + /** + * Emit an event notifying all listeners that this store has changed. + * This can only be invoked when dispatching. + * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. + */ + protected __emitChange(): void; + + /** + * This method encapsulates all logic for invoking __onDispatch. It should + * be used for things like catching changes and emitting them after the + * subclass has handled a payload. + */ + protected __invokeOnDispatch(payload: TPayload): void; + + /** + * Subclasses must override this method. + * This is how the store receives actions from the dispatcher. + * All state mutation logic must be done during this method. + */ + protected __onDispatch(payload: TPayload): void; + + protected __changed: boolean; + + protected __changeEvent: string; + + protected __className: string; + + protected __dispatcher: Dispatcher; + + protected __emitter: fbEmitter.EventEmitter; +} + +export = FluxStore; diff --git a/types/flux/test/Flux.ts b/types/flux/test/Flux.ts new file mode 100644 index 0000000000..6666b830aa --- /dev/null +++ b/types/flux/test/Flux.ts @@ -0,0 +1,71 @@ +import { Dispatcher } from "flux"; + +enum ActionSource { + Server, + View +} +enum ActionType { + Create, + Update, + Delete +} + +interface Action { + source: ActionSource; + type: ActionType; + data: {}; +} + +function dispatcherCallback(payload: Action) { + let source: ActionSource = payload.source; + let type: ActionType = payload.type; + let data: {} = payload.data; +} + +let dispatcherIsDispatching: boolean; +let dispatcherToken: string; + +const actionPayload = { + data: {}, + source: ActionSource.Server, + type: ActionType.Create +}; + +/** + * Basic dispatcher + */ +const basicDispatcher: Dispatcher = new Dispatcher(); +dispatcherToken = basicDispatcher.register(dispatcherCallback); +basicDispatcher.unregister(dispatcherToken); +basicDispatcher.waitFor([dispatcherToken]); +basicDispatcher.dispatch(actionPayload); +dispatcherIsDispatching = basicDispatcher.isDispatching(); + +/** + * Custom dispatcher + */ +class CustomDispatcher extends Dispatcher { + // Dispatch an action with server as source + handleServerAction(type: ActionType, data: {}) { + this.dispatch({ + source: ActionSource.Server, + type, + data + }); + } + // Dispatch an action with view as source + handleViewAction(type: ActionType, data: {}) { + this.dispatch({ + source: ActionSource.View, + type, + data + }); + } +} + +const customDispatcher: CustomDispatcher = new CustomDispatcher(); +dispatcherToken = customDispatcher.register(dispatcherCallback); +customDispatcher.unregister(dispatcherToken); +customDispatcher.dispatch(actionPayload); +customDispatcher.waitFor([dispatcherToken]); +dispatcherIsDispatching = customDispatcher.isDispatching(); diff --git a/types/flux/test/FluxUtils.tsx b/types/flux/test/FluxUtils.tsx new file mode 100644 index 0000000000..1cd3705fab --- /dev/null +++ b/types/flux/test/FluxUtils.tsx @@ -0,0 +1,80 @@ +import { Dispatcher } from "flux"; +import { ReduceStore, Container } from "flux/utils"; +import * as React from "react"; + +interface Payload { + type: string; +} + +const basicDispatcher = new Dispatcher(); + +// Sample Reduce Store +class CounterStore extends ReduceStore { + getInitialState(): number { + return 0; + } + + reduce(state: number, action: Payload): number { + switch (action.type) { + case 'increment': + return state + 1; + case 'square': + return state * state; + default: + return state; + } + } +} +const Store = new CounterStore(basicDispatcher); + +// Sample Flux container with Store +interface Props { + a: string; + b: boolean; +} + +interface State { + counter: number; +} + +class CounterContainer extends React.Component { + static getStores() { + return [Store]; + } + + static a: string = "asd"; + + static calculateState(prevState: State, props: Props): State { + return { + counter: Store.getState() - (props.b ? 0 : 1) + }; + } + + render() { + return

+ {this.state.counter} +
; + } +} + +const ContainerComponent1 = Container.create(CounterContainer, { withProps: true }); +; + +const ContainerComponent2 = Container.create(CounterContainer, { withProps: true }); +; + +const ContainerComponent3 = Container.create(CounterContainer, { withProps: true }); +; + +// Functional flux container with Store +const FunctionalContainerComponent = Container.createFunctional( + (props) => { + return
+ {props.a} {props.b} +
; + }, + () => [Store], + (prevState) => ({ counter: Store.getState() }) +); + +; diff --git a/types/flux/tsconfig.json b/types/flux/tsconfig.json index 45255c7d7a..540faa9d2b 100644 --- a/types/flux/tsconfig.json +++ b/types/flux/tsconfig.json @@ -5,20 +5,27 @@ "es6", "dom" ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ "../" ], + "jsx": "react", "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true }, "files": [ "index.d.ts", - "utils/index.d.ts", - "flux-tests.ts" + "utils.d.ts", + "lib/Dispatcher.d.ts", + "lib/FluxContainer.d.ts", + "lib/FluxMixinLegacy.d.ts", + "lib/FluxReduceStore.d.ts", + "lib/FluxStore.d.ts", + "test/Flux.ts", + "test/FluxUtils.tsx" ] } \ No newline at end of file diff --git a/types/flux/tslint.json b/types/flux/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/flux/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/flux/utils.d.ts b/types/flux/utils.d.ts new file mode 100644 index 0000000000..4eb3d96e99 --- /dev/null +++ b/types/flux/utils.d.ts @@ -0,0 +1,11 @@ +import * as Container from "./lib/FluxContainer"; +import * as Mixin from "./lib/FluxMixinLegacy"; +import * as ReduceStore from "./lib/FluxReduceStore"; +import * as Store from "./lib/FluxStore"; + +export { + Container, + Mixin, + ReduceStore, + Store +}; diff --git a/types/flux/utils/index.d.ts b/types/flux/utils/index.d.ts deleted file mode 100644 index b223945181..0000000000 --- a/types/flux/utils/index.d.ts +++ /dev/null @@ -1,140 +0,0 @@ -// Type definitions for Flux Utils 3.0 -// Project: http://facebook.github.io/flux/ -// Definitions by: Steve Baker , Giedrius Grabauskas -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// - -import * as React from 'react'; -import * as Flux from 'flux'; -import * as fbEmitter from 'fbemitter'; - -export = FluxUtils; - -declare namespace FluxUtils { - /** - * Default options to create a Container with - * - * @interface RealOptions - */ - interface RealOptions { - /** - * Default value: true - * - * @type {boolean} - */ - pure?: boolean; - /** - * Default value: false - * - * @type {boolean} - */ - withProps?: boolean; - /** - * Default value: false - * - * @type {boolean} - */ - withContext?: boolean; - } - - export class Container { - constructor(); - /** - * Create is used to transform a react class into a container - * that updates its state when relevant stores change. - * The provided base class must have static methods getStores() and calculateState(). - */ - static create(base: React.ComponentClass, options?: RealOptions): React.ComponentClass; - - - - /** - * This is a way to connect stores to a functional stateless view - */ - static createFunctional( - viewFn: (props: State) => React.ReactElement, - getStores: (props?: Props, context?: any) => FluxUtils.Store[], - calculateState: (prevState?: State, props?: Props, context?: any) => State, - options?: RealOptions - ): React.ComponentClass; - } - - export class ReduceStore extends Store { - /** - * Getter that exposes the entire state of this store. - * If your state is not immutable you should override this and not expose state directly. - */ - getState(): T; - - /** - * Constructs the initial state for this store. - * This is called once during construction of the store. - */ - getInitialState(): T; - - /** - * Reduces the current state, and an action to the new state of this store. - * All subclasses must implement this method. - * This method should be pure and have no side-effects. - */ - reduce(state: T, action: TPayload): T; - - /** - * Checks if two versions of state are the same. - * You do not need to override this if your state is immutable. - */ - areEqual(one: T, two: T): boolean; - - } - - export class Store { - - /** - * Constructs and registers an instance of this store with the given dispatcher. - */ - constructor(dispatcher: Flux.Dispatcher); - - /** - * Adds a listener to the store, when the store changes the given callback will be called. - * A token is returned that can be used to remove the listener. - * Calling the remove() function on the returned token will remove the listener. - */ - addListener(callback: Function): fbEmitter.EventSubscription; - - /** - * Returns the dispatcher this store is registered with. - */ - getDispatcher(): Flux.Dispatcher; - - /** - * Returns the dispatch token that the dispatcher recognizes this store by. - * Can be used to waitFor() this store. - */ - getDispatchToken(): string; - - /** - * Ask if a store has changed during the current dispatch. - * Can only be invoked while dispatching. - * This can be used for constructing derived stores that depend on data from other stores. - */ - hasChanged(): boolean; - - /** - *Emit an event notifying all listeners that this store has changed. - * This can only be invoked when dispatching. - * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. - */ - __emitChange(): void; - - /** - * Subclasses must override this method. - * This is how the store receives actions from the dispatcher. - * All state mutation logic must be done during this method. - */ - __onDispatch(payload: TPayload): void; - } -} - From 06303669ae82d3e9eea8ac9975c0c683a0b104a7 Mon Sep 17 00:00:00 2001 From: Denis Vishniakov Date: Thu, 4 May 2017 21:07:03 -0400 Subject: [PATCH 11/50] Fixed missing request.OAuthOptions.transport_method (#15927) --- types/request/index.d.ts | 3 ++- types/request/request-tests.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/request/index.d.ts b/types/request/index.d.ts index 41791cf1ad..d27e2e89ed 100644 --- a/types/request/index.d.ts +++ b/types/request/index.d.ts @@ -50,7 +50,7 @@ declare namespace request { del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; del(uri: string, callback?: RequestCallback): TRequest; del(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; - + delete(uri: string, options?: TOptions, callback?: RequestCallback): TRequest; delete(uri: string, callback?: RequestCallback): TRequest; delete(options: TUriUrlOptions & TOptions, callback?: RequestCallback): TRequest; @@ -237,6 +237,7 @@ declare namespace request { consumer_secret?: string; token?: string; token_secret?: string; + transport_method?: 'body' | 'header' | 'query'; verifier?: string; } diff --git a/types/request/request-tests.ts b/types/request/request-tests.ts index 1bd81760c8..7b05a6476b 100644 --- a/types/request/request-tests.ts +++ b/types/request/request-tests.ts @@ -77,6 +77,7 @@ str = oauth.consumer_key; str = oauth.consumer_secret; str = oauth.token; str = oauth.token_secret; +str = oauth.transport_method; str = oauth.verifier; var options: request.Options = { @@ -434,6 +435,7 @@ oauth = { callback: 'http://mysite.com/callback/' , consumer_key: CONSUMER_KEY , consumer_secret: CONSUMER_SECRET + , transport_method: 'header' } , url = 'https://api.twitter.com/oauth/request_token' ; From 208f0dd6a6109c83785c67c33c76c37505b62929 Mon Sep 17 00:00:00 2001 From: Gyusun Yeom Date: Fri, 5 May 2017 10:07:52 +0900 Subject: [PATCH 12/50] upate types of watch for 1.0 (#15931) * Update types of watch for 1.0 * Specify type of File & Options.filter * fix tslint.json - use dtslint/dt.json * fix lint error --- types/watch/index.d.ts | 36 +++++++++++++++------------- types/watch/tsconfig.json | 2 +- types/watch/tslint.json | 1 + types/watch/watch-tests.ts | 49 +++++++++++++++++++++----------------- 4 files changed, 48 insertions(+), 40 deletions(-) create mode 100644 types/watch/tslint.json diff --git a/types/watch/index.d.ts b/types/watch/index.d.ts index 78ffdca016..626d47dbf3 100644 --- a/types/watch/index.d.ts +++ b/types/watch/index.d.ts @@ -1,35 +1,37 @@ -// Type definitions for watch +// Type definitions for watch 1.0 // Project: https://github.com/mikeal/watch -// Definitions by: Carlos Ballesteros Velasco +// Definitions by: Carlos Ballesteros Velasco , Gyusun Yeom // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Imported from: https://github.com/soywiz/typescript-node-definitions/watch.d.ts /// - import fs = require("fs"); import events = require("events"); -export interface Monitor extends events.EventEmitter { - // event: created - // event: removed - // event: changed +export type FileOrFiles = fs.Stats | {[key: string]: fs.Stats}; - // export function onCreated(callback, function(f, stat: fs.Stats) { }); - // export function onChanged(callback, function(f, curr: fs.Stats, prev: fs.Stats) { }); - // export function onRemoved(callback, function(f, stat: fs.Stats) { }); +export interface Monitor extends events.EventEmitter { + files: {[key: string]: fs.Stats}; + + on(event: "created" | "removed", listener: (f: FileOrFiles, stat: fs.Stats) => void): this; + on(event: "changed", listener: (f: FileOrFiles, current: fs.Stats, prev: fs.Stats) => void): this; + on(event: string | symbol, listener: (...args: any[]) => void): this; + stop(): void; } export interface Options { - persistent?: boolean; ignoreDotFiles?: boolean; - filter?: any; + filter?(path: string, stat: fs.Stats): boolean; interval?: number; + ignoreUnreadableDir?: boolean; + ignoreNotPermitted?: boolean; + ignoreDirectoryPattern?: boolean; } -export declare function watchTree(root: string, callback: (f: any, curr: fs.Stats, prev: fs.Stats) => void): void; -export declare function watchTree(root: string, options: Options, callback: (f: any, curr: fs.Stats, prev: fs.Stats) => void): void; -export declare function unwatchTree(root: string): void; -export declare function createMonitor(root: string, callback: (monitor: Monitor) => void): void; -export declare function createMonitor(root: string, options: Options, callback: (monitor: Monitor) => void): void; +export function watchTree(root: string, callback: (f: FileOrFiles, curr: fs.Stats, prev: fs.Stats) => void): void; +export function watchTree(root: string, options: Options, callback: (f: FileOrFiles, curr: fs.Stats, prev: fs.Stats) => void): void; +export function unwatchTree(root: string): void; +export function createMonitor(root: string, callback: (monitor: Monitor) => void): void; +export function createMonitor(root: string, options: Options, callback: (monitor: Monitor) => void): void; diff --git a/types/watch/tsconfig.json b/types/watch/tsconfig.json index 2936f899ce..372f591f92 100644 --- a/types/watch/tsconfig.json +++ b/types/watch/tsconfig.json @@ -19,4 +19,4 @@ "index.d.ts", "watch-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/watch/tslint.json b/types/watch/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/watch/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/watch/watch-tests.ts b/types/watch/watch-tests.ts index 9510d6dfb7..bc78126e11 100644 --- a/types/watch/watch-tests.ts +++ b/types/watch/watch-tests.ts @@ -1,32 +1,37 @@ - import watch = require('watch'); import fs = require('fs'); -var value: any; -var str: string; -var num: number; -var bool: boolean; - -var mon: watch.Monitor; -var opts: watch.Options = { - ignoreDotFiles: bool, - filter: value -}; - -mon.on('foo', () => { - +watch.watchTree('/some_path', (f: any, curr: fs.Stats, prev: fs.Stats) => { }); -watch.watchTree(str, (f: any, curr: fs.Stats, prev: fs.Stats) => { - +watch.watchTree('/home/mikeal', (f, curr, prev) => { + if (typeof f === "object" && prev === null && curr === null) { + // Finished walking the tree + } else if (prev === null) { + // f is a new file + } else if (curr.nlink === 0) { + // f was removed + } else { + // f was changed + } }); -watch.watchTree(str, opts, (f: any, curr: fs.Stats, prev: fs.Stats) => { +watch.unwatchTree('/some_path'); +watch.createMonitor('/home/mikeal', (monitor) => { + monitor.files['/home/mikeal/.zshrc']; // Stat object for my zshrc. + monitor.on("created", (f, stat) => { + // Handle new files + }); + monitor.on("changed", (f, curr, prev) => { + // Handle file changes + }); + monitor.on("removed", (f, stat) => { + // Handle removed files + }); + monitor.stop(); // Stop watching }); -watch.unwatchTree(str); -watch.createMonitor(str, (monitor: watch.Monitor) => { - -}); -watch.createMonitor(str, opts, (monitor: watch.Monitor) => { +watch.createMonitor('/some/path', { + ignoreDotFiles: true +}, (monitor: watch.Monitor) => { }); From 5eb4882512adb3846102242c57d648fc029bee87 Mon Sep 17 00:00:00 2001 From: cafeburger Date: Fri, 5 May 2017 09:08:08 +0800 Subject: [PATCH 13/50] Update index.d.ts (#15937) add 'hosted_domain' property in gapi.client.init --- types/gapi/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/gapi/index.d.ts b/types/gapi/index.d.ts index 8f8e621fa3..9af6258966 100644 --- a/types/gapi/index.d.ts +++ b/types/gapi/index.d.ts @@ -148,7 +148,9 @@ declare namespace gapi.client { /** * The scopes to request, as a space-delimited string. */ - scope?: string + scope?: string, + + hosted_domain?: string; }): Promise; interface RequestOptions { From 5f27bc20941d98ccc42df3a01a306b83b01c5c06 Mon Sep 17 00:00:00 2001 From: Bas Timmer Date: Fri, 5 May 2017 03:08:20 +0200 Subject: [PATCH 14/50] color: Add color model conversions (#15940) --- types/color/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/color/index.d.ts b/types/color/index.d.ts index e7e460f62a..8d6016c7d8 100644 --- a/types/color/index.d.ts +++ b/types/color/index.d.ts @@ -67,6 +67,13 @@ declare namespace Color { hex(color: string): Color; hex(): string; rgb(): Color; + hsl(): Color; + hsv(): Color; + hwb(): Color; + hcg(): Color; + cmyk(): Color; + xyz(): Color; + lab(): Color; rgbNumber(): number; luminosity(): number; contrast(color: Color): number; From c26fe793b8b61294dd08cb0fbf291a43091a23a8 Mon Sep 17 00:00:00 2001 From: Martin Deiss Date: Fri, 5 May 2017 03:08:32 +0200 Subject: [PATCH 15/50] Added missing customPATCH method (#15945) --- types/restangular/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/restangular/index.d.ts b/types/restangular/index.d.ts index 8fbc5723cb..811fdf8894 100644 --- a/types/restangular/index.d.ts +++ b/types/restangular/index.d.ts @@ -76,6 +76,7 @@ declare namespace restangular { customDELETE(path: string, params?: any, headers?: any): IPromise; customPOST(elem?: any, path?: string, params?: any, headers?: any): IPromise; customPUT(elem?: any, path?: string, params?: any, headers?: any): IPromise; + customPATCH(elem?: any, path?: string, params?: any, headers?: any): IPromise; customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): IPromise; addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): IPromise; } From cb8b7aeb33392c04c3082b04eb5d51e8a9744e7f Mon Sep 17 00:00:00 2001 From: Sam Baxter Date: Thu, 4 May 2017 21:09:02 -0400 Subject: [PATCH 16/50] Fix function param type definitions for babel-types (#15973) --- types/babel-types/babel-types-tests.ts | 3 +++ types/babel-types/index.d.ts | 30 +++++++++++++------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/types/babel-types/babel-types-tests.ts b/types/babel-types/babel-types-tests.ts index 7b82dfc675..5974a64885 100644 --- a/types/babel-types/babel-types-tests.ts +++ b/types/babel-types/babel-types-tests.ts @@ -14,6 +14,9 @@ traverse(ast, { if (t.isIdentifier(node, { name: "n" })) { node.name = "x"; } + if (t.isFunctionExpression(node)) { + node.params = [t.identifier('param')]; + } } }); diff --git a/types/babel-types/index.d.ts b/types/babel-types/index.d.ts index 495b818a0b..77ea8b54de 100644 --- a/types/babel-types/index.d.ts +++ b/types/babel-types/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for babel-types v6.7 // Project: https://github.com/babel/babel/tree/master/packages/babel-types -// Definitions by: Troy Gerwien +// Definitions by: Troy Gerwien , Sam Baxter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface Comment { @@ -88,7 +88,7 @@ export interface CallExpression extends Node { export interface CatchClause extends Node { type: "CatchClause"; - param: Pattern; + param: Identifier; body: BlockStatement; } @@ -148,7 +148,7 @@ export interface ForStatement extends Node { export interface FunctionDeclaration extends Node { type: "FunctionDeclaration"; id: Identifier; - params: Pattern[]; + params: Array; body: BlockStatement; generator: boolean; async: boolean; @@ -159,7 +159,7 @@ export interface FunctionDeclaration extends Node { export interface FunctionExpression extends Node { type: "FunctionExpression"; id: Identifier; - params: Pattern[]; + params: Array; body: BlockStatement; generator: boolean; async: boolean; @@ -252,7 +252,7 @@ export interface ObjectMethod extends Node { value: Expression; decorators?: Decorator[]; id: Identifier; - params: Pattern[]; + params: Array; body: BlockStatement; generator: boolean; async: boolean; @@ -353,20 +353,20 @@ export interface WithStatement extends Node { export interface AssignmentPattern extends Node { type: "AssignmentPattern"; - left: Pattern; + left: Identifier; right: Expression; } export interface ArrayPattern extends Node { type: "ArrayPattern"; - elements: Array; + elements: Array; typeAnnotation?: TypeAnnotation; } export interface ArrowFunctionExpression extends Node { type: "ArrowFunctionExpression"; id: Identifier; - params: Pattern[]; + params: Array; body: BlockStatement | Expression; generator: boolean; async: boolean; @@ -472,7 +472,7 @@ export interface ClassMethod extends Node { static: boolean; decorators?: Decorator[]; id: Identifier; - params: Pattern[]; + params: Array; body: BlockStatement; generator: boolean; async: boolean; @@ -925,8 +925,8 @@ export function expressionStatement(expression?: Expression): ExpressionStatemen export function file(program?: Program, comments?: Comment[], tokens?: any[]): File; export function forInStatement(left?: VariableDeclaration | LVal, right?: Expression, body?: Statement): ForInStatement; export function forStatement(init?: VariableDeclaration | Expression, test?: Expression, update?: Expression, body?: Statement): ForStatement; -export function functionDeclaration(id?: Identifier, params?: Pattern[], body?: BlockStatement, generator?: boolean, async?: boolean): FunctionDeclaration; -export function functionExpression(id?: Identifier, params?: Pattern[], body?: BlockStatement, generator?: boolean, async?: boolean): FunctionExpression; +export function functionDeclaration(id?: Identifier, params?: Array, body?: BlockStatement, generator?: boolean, async?: boolean): FunctionDeclaration; +export function functionExpression(id?: Identifier, params?: Array, body?: BlockStatement, generator?: boolean, async?: boolean): FunctionExpression; export function identifier(name?: string): Identifier; export function ifStatement(test?: Expression, consequent?: Statement, alternate?: Statement): IfStatement; export function labeledStatement(label?: Identifier, body?: Statement): LabeledStatement; @@ -940,7 +940,7 @@ export function memberExpression(object?: Expression | Super, property?: Express export function newExpression(callee?: Expression | Super, _arguments?: Array): NewExpression; export function program(body?: Array, directives?: Directive[]): Program; export function objectExpression(properties?: Array): ObjectExpression; -export function objectMethod(kind?: "get" | "set" | "method", key?: Expression, params?: Pattern[], body?: BlockStatement, computed?: boolean): ObjectMethod; +export function objectMethod(kind?: "get" | "set" | "method", key?: Expression, params?: Array, body?: BlockStatement, computed?: boolean): ObjectMethod; export function objectProperty(key?: Expression, value?: Expression, computed?: boolean, shorthand?: boolean, decorators?: Decorator[]): ObjectProperty; export function restElement(argument?: LVal, typeAnnotation?: TypeAnnotation): RestElement; export function returnStatement(argument?: Expression): ReturnStatement; @@ -957,8 +957,8 @@ export function variableDeclarator(id?: LVal, init?: Expression): VariableDeclar export function whileStatement(test?: Expression, body?: BlockStatement | Statement): WhileStatement; export function withStatement(object?: Expression, body?: BlockStatement | Statement): WithStatement; export function assignmentPattern(left?: Identifier, right?: Expression): AssignmentPattern; -export function arrayPattern(elements?: Array, typeAnnotation?: TypeAnnotation): ArrayPattern; -export function arrowFunctionExpression(params?: Pattern[], body?: BlockStatement | Expression, async?: boolean): ArrowFunctionExpression; +export function arrayPattern(elements?: Array, typeAnnotation?: TypeAnnotation): ArrayPattern; +export function arrowFunctionExpression(params?: Array, body?: BlockStatement | Expression, async?: boolean): ArrowFunctionExpression; export function classBody(body?: Array): ClassBody; export function classDeclaration(id?: Identifier, superClass?: Expression, body?: ClassBody, decorators?: Decorator[]): ClassDeclaration; export function classExpression(id?: Identifier, superClass?: Expression, body?: ClassBody, decorators?: Decorator[]): ClassExpression; @@ -972,7 +972,7 @@ export function importDefaultSpecifier(local?: Identifier): ImportDefaultSpecifi export function importNamespaceSpecifier(local?: Identifier): ImportNamespaceSpecifier; export function importSpecifier(local?: Identifier, imported?: Identifier): ImportSpecifier; export function metaProperty(meta?: string, property?: string): MetaProperty; -export function classMethod(kind?: "constructor" | "method" | "get" | "set", key?: Expression, params?: Pattern[], body?: BlockStatement, computed?: boolean, _static?: boolean): ClassMethod; +export function classMethod(kind?: "constructor" | "method" | "get" | "set", key?: Expression, params?: Array, body?: BlockStatement, computed?: boolean, _static?: boolean): ClassMethod; export function objectPattern(properties?: Array, typeAnnotation?: TypeAnnotation): ObjectPattern; export function spreadElement(argument?: Expression): SpreadElement; export function taggedTemplateExpression(tag?: Expression, quasi?: TemplateLiteral): TaggedTemplateExpression; From 3eb6786902b36f0324512b15389b7fbb4c3e8735 Mon Sep 17 00:00:00 2001 From: Brian Houser Date: Fri, 5 May 2017 03:10:22 +0200 Subject: [PATCH 17/50] react-intl: update IntlProvider.Props interface (#15977) * update IntlProvider.Props interface * updated react-intl "Definitions by" --- types/react-intl/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 44480deceb..5fb82ada78 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -4,7 +4,8 @@ // Christian Droulers , // Fedor Nezhivoi , // Till Wolff , -// Karol Janyst +// Karol Janyst , +// Brian Houser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -186,6 +187,7 @@ declare namespace ReactIntl { messages?: any; defaultLocale?: string; defaultFormats?: any; + textComponent?: any; } } From 76c82115adf826119103465a2a45ca272a3c7752 Mon Sep 17 00:00:00 2001 From: DingWeizhe Date: Fri, 5 May 2017 09:13:03 +0800 Subject: [PATCH 18/50] [fluent-ffmpeg] support es6 import syntax & conform to tdslint (#16036) * support es6 import syntax * support es6 import syntax * add author * test import syntax to es6 * add tslint config * tslint: Interface has only a call signature * tslint: ban-types * tslint: no-misused-new * tslint: semicolon * tslint: TypeScript compile error: Cannot find name 'object'. * tslint: unified-signatures * tslint: disable unified-signatures, parameter name is different * tslint: object-literal-shorthand * tslint: one-variable-per-declaration * tslint: dt-header * tslint: no-single-declare-module * type definitions for images 2.2 --- types/fluent-ffmpeg/fluent-ffmpeg-tests.ts | 8 +- types/fluent-ffmpeg/index.d.ts | 489 ++++++++++----------- types/fluent-ffmpeg/tslint.json | 3 + types/images/images-tests.ts | 35 ++ types/images/index.d.ts | 43 ++ types/images/tsconfig.json | 22 + types/images/tslint.json | 3 + 7 files changed, 350 insertions(+), 253 deletions(-) create mode 100644 types/fluent-ffmpeg/tslint.json create mode 100644 types/images/images-tests.ts create mode 100644 types/images/index.d.ts create mode 100644 types/images/tsconfig.json create mode 100644 types/images/tslint.json diff --git a/types/fluent-ffmpeg/fluent-ffmpeg-tests.ts b/types/fluent-ffmpeg/fluent-ffmpeg-tests.ts index 112d6de09b..b4beb14ef7 100644 --- a/types/fluent-ffmpeg/fluent-ffmpeg-tests.ts +++ b/types/fluent-ffmpeg/fluent-ffmpeg-tests.ts @@ -1,5 +1,7 @@ -import ffmpeg = require("fluent-ffmpeg") +import * as ffmpeg from "fluent-ffmpeg"; -let source: string, format: string, output: string +let source: string; +let format: string; +let output: string; -ffmpeg({ source: source }).format(format).save(output) +ffmpeg({ source }).format(format).save(output); diff --git a/types/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index 538ac71761..1e44422789 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -1,315 +1,304 @@ -// Type definitions for node-fluent-ffmpeg +// Type definitions for node-fluent-ffmpeg 2.1 // Project: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg -// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk +// Definitions by: KIM Jaesuck a.k.a. gim tcaesvk , DingWeizhe // Definitions: https://github.com/DefinitelyType/DefinitelyTyped /// -declare module "fluent-ffmpeg" { - import * as events from "events" - import * as stream from "stream" +import * as events from "events"; +import * as stream from "stream"; +declare namespace Ffmpeg { interface FfmpegCommandLogger { - error(...data: any[]): void - warning(...data: any[]): void - info(...data: any[]): void - debug(...data: any[]): void + error(...data: any[]): void; + warning(...data: any[]): void; + info(...data: any[]): void; + debug(...data: any[]): void; } interface FfmpegCommandOptions { - logger?: FfmpegCommandLogger - niceness?: number - priority?: number - presets?: string - preset?: string - stdoutLines?: number - timeout?: number - source?: string | stream.Readable + logger?: FfmpegCommandLogger; + niceness?: number; + priority?: number; + presets?: string; + preset?: string; + stdoutLines?: number; + timeout?: number; + source?: string | stream.Readable; } interface FilterSpecification { - filter: string - inputs: string | string[] - outputs: string | string[] - options?: Object | string | any[] + filter: string; + inputs: string | string[]; + outputs: string | string[]; + options?: any | string | any[]; } - interface GetPreset { - (command: FfmpegCommand): string - } + type GetPreset = (command: FfmpegCommand) => string; interface Filter { - description: string - input: string - multipleInputs: boolean - output: string - multipleOutputs: boolean + description: string; + input: string; + multipleInputs: boolean; + output: string; + multipleOutputs: boolean; } interface Filters { - [key: string]: Filter - } - interface FiltersCallback { - (err: Error, filters: Filters): void + [key: string]: Filter; } + type FiltersCallback = (err: Error, filters: Filters) => void; interface Codec { - type: string - description: string - canDecode: boolean - canEncode: boolean - drawHorizBand?: boolean - directRendering?: boolean - weirdFrameTruncation?: boolean - intraFrameOnly?: boolean - isLossy?: boolean - isLossless?: boolean + type: string; + description: string; + canDecode: boolean; + canEncode: boolean; + drawHorizBand?: boolean; + directRendering?: boolean; + weirdFrameTruncation?: boolean; + intraFrameOnly?: boolean; + isLossy?: boolean; + isLossless?: boolean; } interface Codecs { - [key: string]: Codec - } - interface CodecsCallback { - (err: Error, codecs: Codecs): void + [key: string]: Codec; } + type CodecsCallback = (err: Error, codecs: Codecs) => void; interface Encoder { - type: string - description: string - frameMT: boolean - sliceMT: boolean - experimental: boolean - drawHorizBand: boolean - directRendering: boolean + type: string; + description: string; + frameMT: boolean; + sliceMT: boolean; + experimental: boolean; + drawHorizBand: boolean; + directRendering: boolean; } interface Encoders { - [key: string]: Encoder - } - interface EncodersCallback { - (err: Error, encoders: Encoders): void + [key: string]: Encoder; } + type EncodersCallback = (err: Error, encoders: Encoders) => void; interface Format { - description: string - canDemux: boolean - canMux: boolean + description: string; + canDemux: boolean; + canMux: boolean; } interface Formats { - [key: string]: Format - } - interface FormatsCallback { - (err: Error, formats: Formats): void + [key: string]: Format; } + type FormatsCallback = (err: Error, formats: Formats) => void; interface FfprobeData { - stream: any[] - format: any - chapters: any[] + stream: any[]; + format: any; + chapters: any[]; } interface ScreenshotsConfig { - count?: number - folder?: string - filename?: string - timemarks?: number[] | string[] - timestamps?: number[] | string[] - fastSeek?: boolean - size?: string + count?: number; + folder?: string; + filename?: string; + timemarks?: number[] | string[]; + timestamps?: number[] | string[]; + fastSeek?: boolean; + size?: string; } - interface FfmpegCommand extends events.EventEmitter { - constructor(): FfmpegCommand - constructor(options: FfmpegCommandOptions): FfmpegCommand - constructor(input: string | stream.Readable, options: FfmpegCommandOptions): FfmpegCommand + class FfmpegCommand extends events.EventEmitter { + constructor(options?: FfmpegCommandOptions); + constructor(input?: string | stream.Readable, options?: FfmpegCommandOptions); // options/inputs - mergeAdd(source: string | stream.Readable): FfmpegCommand - addInput(source: string | stream.Readable): FfmpegCommand - input(source: string | stream.Readable): FfmpegCommand - withInputFormat(format: string): FfmpegCommand - inputFormat(format: string): FfmpegCommand - fromFormat(format: string): FfmpegCommand - withInputFps(fps: number): FfmpegCommand - withInputFPS(fps: number): FfmpegCommand - withFpsInput(fps: number): FfmpegCommand - withFPSInput(fps: number): FfmpegCommand - inputFPS(fps: number): FfmpegCommand - inputFps(fps: number): FfmpegCommand - fpsInput(fps: number): FfmpegCommand - FPSInput(fps: number): FfmpegCommand - nativeFramerate(): FfmpegCommand - withNativeFramerate(): FfmpegCommand - native(): FfmpegCommand - setStartTime(seek: string | number): FfmpegCommand - seekInput(seek: string | number): FfmpegCommand - loop(duration: string | number): FfmpegCommand + mergeAdd(source: string | stream.Readable): FfmpegCommand; + addInput(source: string | stream.Readable): FfmpegCommand; + input(source: string | stream.Readable): FfmpegCommand; + withInputFormat(format: string): FfmpegCommand; + inputFormat(format: string): FfmpegCommand; + fromFormat(format: string): FfmpegCommand; + withInputFps(fps: number): FfmpegCommand; + withInputFPS(fps: number): FfmpegCommand; + withFpsInput(fps: number): FfmpegCommand; + withFPSInput(fps: number): FfmpegCommand; + inputFPS(fps: number): FfmpegCommand; + inputFps(fps: number): FfmpegCommand; + fpsInput(fps: number): FfmpegCommand; + FPSInput(fps: number): FfmpegCommand; + nativeFramerate(): FfmpegCommand; + withNativeFramerate(): FfmpegCommand; + native(): FfmpegCommand; + setStartTime(seek: string | number): FfmpegCommand; + seekInput(seek: string | number): FfmpegCommand; + loop(duration: string | number): FfmpegCommand; // options/audio - withNoAudio(): FfmpegCommand - noAudio(): FfmpegCommand - withAudioCodec(codec: string): FfmpegCommand - audioCodec(codec: string): FfmpegCommand - withAudioBitrate(bitrate: string | number): FfmpegCommand - audioBitrate(bitrate: string | number): FfmpegCommand - withAudioChannels(channels: number): FfmpegCommand - audioChannels(channels: number): FfmpegCommand - withAudioFrequency(freq: number): FfmpegCommand - audioFrequency(freq: number): FfmpegCommand - withAudioQuality(quality: number): FfmpegCommand - audioQuality(quality: number): FfmpegCommand - withAudioFilter(filters: { filter: string, options: any }): FfmpegCommand - withAudioFilters(filters: { filter: string, options: any }): FfmpegCommand - audioFilter(filters: { filter: string, options: any }): FfmpegCommand - audioFilters(filters: { filter: string, options: any }): FfmpegCommand + withNoAudio(): FfmpegCommand; + noAudio(): FfmpegCommand; + withAudioCodec(codec: string): FfmpegCommand; + audioCodec(codec: string): FfmpegCommand; + withAudioBitrate(bitrate: string | number): FfmpegCommand; + audioBitrate(bitrate: string | number): FfmpegCommand; + withAudioChannels(channels: number): FfmpegCommand; + audioChannels(channels: number): FfmpegCommand; + withAudioFrequency(freq: number): FfmpegCommand; + audioFrequency(freq: number): FfmpegCommand; + withAudioQuality(quality: number): FfmpegCommand; + audioQuality(quality: number): FfmpegCommand; + withAudioFilter(filters: { filter: string, options: any }): FfmpegCommand; + withAudioFilters(filters: { filter: string, options: any }): FfmpegCommand; + audioFilter(filters: { filter: string, options: any }): FfmpegCommand; + audioFilters(filters: { filter: string, options: any }): FfmpegCommand; - // options/video - withNoVideo(): FfmpegCommand - noVideo(): FfmpegCommand - withVideoCodec(codec: string): FfmpegCommand - videoCodec(codec: string): FfmpegCommand - withVideoBitrate(bitrate: string | number): FfmpegCommand - videoBitrate(bitrate: string | number): FfmpegCommand - withVideoFilter(filters: { filter: string, options: any }): FfmpegCommand - withVideoFilters(filters: { filter: string, options: any }): FfmpegCommand - videoFilter(filters: { filter: string, options: any }): FfmpegCommand - videoFilters(filters: { filter: string, options: any }): FfmpegCommand - withOutputFps(fps: number): FfmpegCommand - withOutputFPS(fps: number): FfmpegCommand - withFpsOutput(fps: number): FfmpegCommand - withFPSOutput(fps: number): FfmpegCommand - withFps(fps: number): FfmpegCommand - withFPS(fps: number): FfmpegCommand - outputFPS(fps: number): FfmpegCommand - outputFps(fps: number): FfmpegCommand - fpsOutput(fps: number): FfmpegCommand - FPSOutput(fps: number): FfmpegCommand - fps(fps: number): FfmpegCommand - FPS(fps: number): FfmpegCommand - takeFrames(frames: number): FfmpegCommand - withFrames(frames: number): FfmpegCommand - frames(frames: number): FfmpegCommand + // options/video; + withNoVideo(): FfmpegCommand; + noVideo(): FfmpegCommand; + withVideoCodec(codec: string): FfmpegCommand; + videoCodec(codec: string): FfmpegCommand; + withVideoBitrate(bitrate: string | number): FfmpegCommand; + videoBitrate(bitrate: string | number): FfmpegCommand; + withVideoFilter(filters: { filter: string, options: any }): FfmpegCommand; + withVideoFilters(filters: { filter: string, options: any }): FfmpegCommand; + videoFilter(filters: { filter: string, options: any }): FfmpegCommand; + videoFilters(filters: { filter: string, options: any }): FfmpegCommand; + withOutputFps(fps: number): FfmpegCommand; + withOutputFPS(fps: number): FfmpegCommand; + withFpsOutput(fps: number): FfmpegCommand; + withFPSOutput(fps: number): FfmpegCommand; + withFps(fps: number): FfmpegCommand; + withFPS(fps: number): FfmpegCommand; + outputFPS(fps: number): FfmpegCommand; + outputFps(fps: number): FfmpegCommand; + fpsOutput(fps: number): FfmpegCommand; + FPSOutput(fps: number): FfmpegCommand; + fps(fps: number): FfmpegCommand; + FPS(fps: number): FfmpegCommand; + takeFrames(frames: number): FfmpegCommand; + withFrames(frames: number): FfmpegCommand; + frames(frames: number): FfmpegCommand; // options/videosize - keepPixelAspect(): FfmpegCommand - keepDisplayAspect(): FfmpegCommand - keepDisplayAspectRatio(): FfmpegCommand - keepDAR(): FfmpegCommand - withSize(size: string): FfmpegCommand - setSize(size: string): FfmpegCommand - size(size: string): FfmpegCommand - withAspect(aspect: string | number): FfmpegCommand - withAspectRatio(aspect: string | number): FfmpegCommand - setAspect(aspect: string | number): FfmpegCommand - setAspectRatio(aspect: string | number): FfmpegCommand - aspect(aspect: string | number): FfmpegCommand - aspectRatio(aspect: string | number): FfmpegCommand - applyAutopadding(pad: boolean, color: string): FfmpegCommand - applyAutoPadding(pad: boolean, color: string): FfmpegCommand - applyAutopad(pad: boolean, color: string): FfmpegCommand - applyAutoPad(pad: boolean, color: string): FfmpegCommand - withAutopadding(pad: boolean, color: string): FfmpegCommand - withAutoPadding(pad: boolean, color: string): FfmpegCommand - withAutopad(pad: boolean, color: string): FfmpegCommand - withAutoPad(pad: boolean, color: string): FfmpegCommand - autoPad(pad: boolean, color: string): FfmpegCommand - autopad(pad: boolean, color: string): FfmpegCommand + keepPixelAspect(): FfmpegCommand; + keepDisplayAspect(): FfmpegCommand; + keepDisplayAspectRatio(): FfmpegCommand; + keepDAR(): FfmpegCommand; + withSize(size: string): FfmpegCommand; + setSize(size: string): FfmpegCommand; + size(size: string): FfmpegCommand; + withAspect(aspect: string | number): FfmpegCommand; + withAspectRatio(aspect: string | number): FfmpegCommand; + setAspect(aspect: string | number): FfmpegCommand; + setAspectRatio(aspect: string | number): FfmpegCommand; + aspect(aspect: string | number): FfmpegCommand; + aspectRatio(aspect: string | number): FfmpegCommand; + applyAutopadding(pad: boolean, color: string): FfmpegCommand; + applyAutoPadding(pad: boolean, color: string): FfmpegCommand; + applyAutopad(pad: boolean, color: string): FfmpegCommand; + applyAutoPad(pad: boolean, color: string): FfmpegCommand; + withAutopadding(pad: boolean, color: string): FfmpegCommand; + withAutoPadding(pad: boolean, color: string): FfmpegCommand; + withAutopad(pad: boolean, color: string): FfmpegCommand; + withAutoPad(pad: boolean, color: string): FfmpegCommand; + autoPad(pad: boolean, color: string): FfmpegCommand; + autopad(pad: boolean, color: string): FfmpegCommand; // options/output - addOutput(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand - output(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand - seekOutput(seek: string | number): FfmpegCommand - seek(seek: string | number): FfmpegCommand - withDuration(duration: string | number): FfmpegCommand - setDuration(duration: string | number): FfmpegCommand - duration(duration: string | number): FfmpegCommand - toFormat(format: string): FfmpegCommand - withOutputFormat(format: string): FfmpegCommand - outputFormat(format: string): FfmpegCommand - format(format: string): FfmpegCommand - map(spec: string): FfmpegCommand - updateFlvMetadata(): FfmpegCommand - flvmeta(): FfmpegCommand + addOutput(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand; + output(target: string | stream.Writable, pipeopts?: { end?: boolean }): FfmpegCommand; + seekOutput(seek: string | number): FfmpegCommand; + seek(seek: string | number): FfmpegCommand; + withDuration(duration: string | number): FfmpegCommand; + setDuration(duration: string | number): FfmpegCommand; + duration(duration: string | number): FfmpegCommand; + toFormat(format: string): FfmpegCommand; + withOutputFormat(format: string): FfmpegCommand; + outputFormat(format: string): FfmpegCommand; + format(format: string): FfmpegCommand; + map(spec: string): FfmpegCommand; + updateFlvMetadata(): FfmpegCommand; + flvmeta(): FfmpegCommand; // options/custom - addInputOption(options: string[]): FfmpegCommand - addInputOption(...options: string[]): FfmpegCommand - addInputOptions(options: string[]): FfmpegCommand - addInputOptions(...options: string[]): FfmpegCommand - withInputOption(options: string[]): FfmpegCommand - withInputOption(...options: string[]): FfmpegCommand - withInputOptions(options: string[]): FfmpegCommand - withInputOptions(...options: string[]): FfmpegCommand - inputOption(options: string[]): FfmpegCommand - inputOption(...options: string[]): FfmpegCommand - inputOptions(options: string[]): FfmpegCommand - inputOptions(...options: string[]): FfmpegCommand - addOutputOption(options: string[]): FfmpegCommand - addOutputOption(...options: string[]): FfmpegCommand - addOutputOptions(options: string[]): FfmpegCommand - addOutputOptions(...options: string[]): FfmpegCommand - addOption(options: string[]): FfmpegCommand - addOption(...options: string[]): FfmpegCommand - addOptions(options: string[]): FfmpegCommand - addOptions(...options: string[]): FfmpegCommand - withOutputOption(options: string[]): FfmpegCommand - withOutputOption(...options: string[]): FfmpegCommand - withOutputOptions(options: string[]): FfmpegCommand - withOutputOptions(...options: string[]): FfmpegCommand - withOption(options: string[]): FfmpegCommand - withOption(...options: string[]): FfmpegCommand - withOptions(options: string[]): FfmpegCommand - withOptions(...options: string[]): FfmpegCommand - outputOption(options: string[]): FfmpegCommand - outputOption(...options: string[]): FfmpegCommand - outputOptions(options: string[]): FfmpegCommand - outputOptions(...options: string[]): FfmpegCommand - filterGraph(spec: string | FilterSpecification[], map: string[]): FfmpegCommand - complexFilter(spec: string | FilterSpecification[], map: string[]): FfmpegCommand + addInputOption(options: string[]): FfmpegCommand; + addInputOption(...options: string[]): FfmpegCommand; + addInputOptions(options: string[]): FfmpegCommand; + addInputOptions(...options: string[]): FfmpegCommand; + withInputOption(options: string[]): FfmpegCommand; + withInputOption(...options: string[]): FfmpegCommand; + withInputOptions(options: string[]): FfmpegCommand; + withInputOptions(...options: string[]): FfmpegCommand; + inputOption(options: string[]): FfmpegCommand; + inputOption(...options: string[]): FfmpegCommand; + inputOptions(options: string[]): FfmpegCommand; + inputOptions(...options: string[]): FfmpegCommand; + addOutputOption(options: string[]): FfmpegCommand; + addOutputOption(...options: string[]): FfmpegCommand; + addOutputOptions(options: string[]): FfmpegCommand; + addOutputOptions(...options: string[]): FfmpegCommand; + addOption(options: string[]): FfmpegCommand; + addOption(...options: string[]): FfmpegCommand; + addOptions(options: string[]): FfmpegCommand; + addOptions(...options: string[]): FfmpegCommand; + withOutputOption(options: string[]): FfmpegCommand; + withOutputOption(...options: string[]): FfmpegCommand; + withOutputOptions(options: string[]): FfmpegCommand; + withOutputOptions(...options: string[]): FfmpegCommand; + withOption(options: string[]): FfmpegCommand; + withOption(...options: string[]): FfmpegCommand; + withOptions(options: string[]): FfmpegCommand; + withOptions(...options: string[]): FfmpegCommand; + outputOption(options: string[]): FfmpegCommand; + outputOption(...options: string[]): FfmpegCommand; + outputOptions(options: string[]): FfmpegCommand; + outputOptions(...options: string[]): FfmpegCommand; + filterGraph(spec: string | FilterSpecification[], map: string[]): FfmpegCommand; + complexFilter(spec: string | FilterSpecification[], map: string[]): FfmpegCommand; // options/misc - usingPreset(proset: string | GetPreset): FfmpegCommand - pnreset(proset: string | GetPreset): FfmpegCommand + usingPreset(proset: string | GetPreset): FfmpegCommand; + pnreset(proset: string | GetPreset): FfmpegCommand; // processor - renice(niceness: number): FfmpegCommand - kill(signal: string): FfmpegCommand + renice(niceness: number): FfmpegCommand; + kill(signal: string): FfmpegCommand; // capabilities - setFfmpegPath(path: string): FfmpegCommand - setFfprobePath(path: string): FfmpegCommand - setFlvtoolPath(path: string): FfmpegCommand - availableFilters(callback: FiltersCallback): void - getAvailableFilters(callback: FiltersCallback): void - availableCodecs(callback: CodecsCallback): void - getAvailableCodecs(callback: CodecsCallback): void - availableEncoders(callback: EncodersCallback): void - getAvailableEncoders(callback: EncodersCallback): void - availableFormats(callback: FormatsCallback): void - getAvailableFormats(callback: FormatsCallback): void + setFfmpegPath(path: string): FfmpegCommand; + setFfprobePath(path: string): FfmpegCommand; + setFlvtoolPath(path: string): FfmpegCommand; + availableFilters(callback: FiltersCallback): void; + getAvailableFilters(callback: FiltersCallback): void; + availableCodecs(callback: CodecsCallback): void; + getAvailableCodecs(callback: CodecsCallback): void; + availableEncoders(callback: EncodersCallback): void; + getAvailableEncoders(callback: EncodersCallback): void; + availableFormats(callback: FormatsCallback): void; + getAvailableFormats(callback: FormatsCallback): void; // ffprobe - ffprobe(callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void - ffprobe(index: number, callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void - ffprobe(options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void - ffprobe(index: number, options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void + /* tslint:disable:unified-signatures */ + ffprobe(callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void; + ffprobe(index: number, callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void; + ffprobe(options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void; + ffprobe(index: number, options: string[], callback: (err: any, data: FfprobeData) => void): (err: any, data: FfprobeData) => void; + /* tslint:enable:unified-signatures */ // recipes - saveToFile(output: string): FfmpegCommand - save(output: string): FfmpegCommand - writeToStream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable - pipe(stream: stream.Writable, options?: { end?: boolean }): stream.Writable - stream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable - takeScreenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand - thumbnail(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand - thumbnails(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand - screenshot(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand - screenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand - mergeToFile(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand - concatenate(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand - concat(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand + saveToFile(output: string): FfmpegCommand; + save(output: string): FfmpegCommand; + writeToStream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable; + pipe(stream: stream.Writable, options?: { end?: boolean }): stream.Writable; + stream(stream: stream.Writable, options?: { end?: boolean }): stream.Writable; + takeScreenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + thumbnail(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + thumbnails(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + screenshot(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + screenshots(config: number | ScreenshotsConfig, folder?: string): FfmpegCommand; + mergeToFile(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; + concatenate(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; + concat(target: string | stream.Writable, options?: { end?: boolean }): FfmpegCommand; } - - function Ffmpeg(): FfmpegCommand - function Ffmpeg(options: FfmpegCommandOptions): FfmpegCommand - function Ffmpeg(input: string | stream.Readable, options: FfmpegCommandOptions): FfmpegCommand - - export = Ffmpeg } +declare function Ffmpeg(options?: Ffmpeg.FfmpegCommandOptions): Ffmpeg.FfmpegCommand; +declare function Ffmpeg(input?: string | stream.Readable, options?: Ffmpeg.FfmpegCommandOptions): Ffmpeg.FfmpegCommand; + +export = Ffmpeg; diff --git a/types/fluent-ffmpeg/tslint.json b/types/fluent-ffmpeg/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fluent-ffmpeg/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/images/images-tests.ts b/types/images/images-tests.ts new file mode 100644 index 0000000000..fc5cab619b --- /dev/null +++ b/types/images/images-tests.ts @@ -0,0 +1,35 @@ +import * as images from "images"; + +// from https://github.com/zhangyuanwei/node-images/blob/master/demo/uploadServer.js +let tmp_path = "tmp_path"; +let out_path = "out_path"; +let photo = images(tmp_path); + +photo.size(800) + .draw(images('./logo.png'), 800 - 421, photo.height() - 117) + .save(out_path, { quality: 80 }); + +// from https://github.com/zhangyuanwei/node-images/blob/master/test/index.js +images("input.png") + .resize(200) + .save("output_new.png"); + +images("input.png") + .size(200) + .save("output_old.png"); + +images("input.jpg") + .resize(200) + .save("output_new.jpg"); + +images("input.jpg") + .size(200) + .save("output_old.jpg"); + +images("input.gif") + .resize(200) + .save("output_new_gif.jpg"); + +images("input.gif") + .size(200) + .save("output_old_gif.jpg"); diff --git a/types/images/index.d.ts b/types/images/index.d.ts new file mode 100644 index 0000000000..38484bb256 --- /dev/null +++ b/types/images/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for images 2.2 +// Project: https://github.com/zhangyuanwei/node-images +// Definitions by: Ding Weizhe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace images { + interface ImagesConfig { + [key: string]: any; + } + type SupportType = "png" | "jpg" | "gif" | "bmp" | "raw" | "webp"; + class ImagesStatic { + fill(red: number, green: number, blue: number, alpha?: number): ImagesStatic; + draw(image: ImagesStatic, x: number, y: number): ImagesStatic; + loadFromBuffer(buffer: Buffer): ImagesStatic; + encode(type: string, config?: ImagesConfig): void; + save(file: string, type?: SupportType, config?: ImagesConfig): void; + save(file: string, config?: ImagesConfig): void; + size(): { width: number, height: number }; + size(width: number, height?: number): ImagesStatic; + resize(width: number, height?: number, filter?: string): ImagesStatic; + resize(width: number, height: number, filter?: string): ImagesStatic; + width(): number; + width(width: number): ImagesStatic; + height(): number; + height(height: number): ImagesStatic; + setLimit(width: number, height: number): void; + setGCThreshold(value: number): void; + getUsedMemory(): void; + gc(): void; + } +} + +/* tslint:disable:unified-signatures */ +declare function images(file: string): images.ImagesStatic; +declare function images(width: number, height: number): images.ImagesStatic; +declare function images(buffer: Buffer, start?: number, end?: number): images.ImagesStatic; +declare function images(image: images.ImagesStatic): images.ImagesStatic; +declare function images(image: images.ImagesStatic, x: number, y: number, width: number, height: number): images.ImagesStatic; +/* tslint:enable:unified-signatures */ + +export = images; diff --git a/types/images/tsconfig.json b/types/images/tsconfig.json new file mode 100644 index 0000000000..7a261dbc3f --- /dev/null +++ b/types/images/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "images-tests.ts" + ] +} diff --git a/types/images/tslint.json b/types/images/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/images/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From f3b9cb6f5173c36695c4d3cb39a950c6448ddaf2 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 4 May 2017 22:14:45 -0300 Subject: [PATCH 19/50] Split levelup/leveldown into separate declarations (#16062) * Split levelup/leveldown into separate declarations Also make some changes to allow importing levelup with ES6 module syntax. * Adapt level-sublevel to the latest changes in levelup --- types/level-sublevel/index.d.ts | 17 ++-- types/leveldown/index.d.ts | 145 +++++++++++++++++++++++++++++ types/leveldown/leveldown-tests.ts | 86 +++++++++++++++++ types/leveldown/tsconfig.json | 22 +++++ types/leveldown/tslint.json | 1 + types/levelup/index.d.ts | 31 +++--- types/levelup/levelup-tests.ts | 6 +- 7 files changed, 282 insertions(+), 26 deletions(-) create mode 100644 types/leveldown/index.d.ts create mode 100644 types/leveldown/leveldown-tests.ts create mode 100644 types/leveldown/tsconfig.json create mode 100644 types/leveldown/tslint.json diff --git a/types/level-sublevel/index.d.ts b/types/level-sublevel/index.d.ts index f6a8f30943..9db592ec0f 100644 --- a/types/level-sublevel/index.d.ts +++ b/types/level-sublevel/index.d.ts @@ -3,22 +3,25 @@ // Definitions by: Bas Pennings // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as levelup from "levelup"; +export = sublevel + +declare var sublevel: sublevel.Constructor; + +declare namespace sublevel { interface Hook { (ch: any, add: (op: Batch|boolean) => void): void; } -interface Batch { +interface Batch extends levelup.Batch { prefix?: Sublevel; } -interface Sublevel extends LevelUp { +interface Sublevel extends levelup.LevelUpBase { sublevel(key: string): Sublevel; pre(hook: Hook): Function; } -declare module "level-sublevel" { - function sublevel(levelup: LevelUp): Sublevel; - export = sublevel; -} \ No newline at end of file +type Constructor = (levelup: levelup.LevelUp) => Sublevel +} diff --git a/types/leveldown/index.d.ts b/types/leveldown/index.d.ts new file mode 100644 index 0000000000..51630dc602 --- /dev/null +++ b/types/leveldown/index.d.ts @@ -0,0 +1,145 @@ +// Type definitions for LevelDown 1.7 +// Project: https://github.com/level/leveldown +// Definitions by: Thiago de Arruda +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = leveldown; + +declare var leveldown: leveldown.Constructor; + +declare namespace leveldown { +type Bytes = string | Buffer; +type ErrCallback = (error: any) => void; +type ErrNumberCallback = (error: any, value: number) => void; +type ErrBufferCallback = (error: any, value: Buffer) => void; +type ErrStringCallback = (error: any, value: string) => void; +type KeyAsStringCallback = (error: any, key: string, value: Buffer) => void; +type ValueAsStringCallback = (error: any, key: Buffer, value: string) => void; +type KeyAndValueAsStringCallback = (error: any, key: string, value: string) => void; +type KeyAndValueAsBufferCallback = (error: any, key: Buffer, value: Buffer) => void; + +interface PutBatch { + type: "put"; + key: Bytes; + value: Bytes; +} + +interface DelBatch { + type: "del"; + key: Bytes; +} + +type Batch = PutBatch | DelBatch; + +interface OpenOptions { + createIfMissing?: boolean; + errorIfExists?: boolean; + compression?: boolean; + cacheSize?: number; +} + +interface OpenAdvancedOptions extends OpenOptions { + writeBufferSize?: number; + blockSize?: number; + maxOpenFiles?: number; + blockRestartInterval?: number; + maxFileSize?: number; +} + +interface WriteOptions { + sync?: boolean; +} + +interface ReadOptions { + fillCache?: boolean; +} + +interface BufferReadOptions extends ReadOptions { + asBuffer?: true; +} + +interface StringReadOptions extends ReadOptions { + asBuffer: false; +} + +interface IteratorOptions { + gt?: Bytes; + lt?: Bytes; + gte?: Bytes; + lte?: Bytes; + reverse?: boolean; + keys?: boolean; + values?: boolean; + limit?: number; + fillCache?: boolean; +} + +interface KeyAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer: false; + valueAsBuffer?: true; +} + +interface ValueAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer?: true; + valueAsBuffer: false; +} + +interface KeyAndValueAsStringIteratorOptions extends IteratorOptions { + keyAsBuffer: false; + valueAsBuffer: false; +} + +interface KeyAndValueAsBufferIteratorOptions extends IteratorOptions { + keyAsBuffer?: true; + valueAsBuffer?: true; +} + +interface Iterator { + seek(key: Bytes): void; + end(callback: ErrCallback): void; +} + +interface KeyAsStringIterator extends Iterator { + next(callback: KeyAsStringCallback): void; +} + +interface ValueAsStringIterator extends Iterator { + next(callback: ValueAsStringCallback): void; +} + +interface KeyAndValueAsStringIterator extends Iterator { + next(callback: KeyAndValueAsStringCallback): void; +} + +interface KeyAndValueAsBufferIterator extends Iterator { + next(callback: KeyAndValueAsBufferCallback): void; +} + +interface LevelDown { + open(callback: ErrCallback): void; + open(options: OpenOptions, callback: ErrCallback): void; + close(callback?: ErrCallback): void; + put(key: Bytes, value: Bytes, callback: ErrCallback): void; + put(key: Bytes, value: Bytes, options: WriteOptions, callback: ErrCallback): void; + get(key: Bytes, callback: ErrBufferCallback): void; + get(key: Bytes, options: BufferReadOptions, callback: ErrBufferCallback): void; + get(key: Bytes, options: StringReadOptions, callback: ErrStringCallback): void; + del(key: Bytes, callback?: ErrCallback): void; + del(key: Bytes, options: WriteOptions, callback?: ErrCallback): void; + batch(operations: Batch[], callback?: ErrCallback): void; + batch(operations: Batch[], options?: WriteOptions, callback?: ErrCallback): void; + approximateSize(start: Bytes, end: Bytes, callback: ErrNumberCallback): void; + compactRange(start: Bytes, end: Bytes, callback: ErrCallback): void; + getProperty(property: string): string; + iterator(options?: KeyAsStringIteratorOptions): KeyAsStringIterator; + iterator(options?: ValueAsStringIteratorOptions): ValueAsStringIterator; + iterator(options?: KeyAndValueAsStringIteratorOptions): KeyAndValueAsStringIterator; + iterator(options?: KeyAndValueAsBufferIteratorOptions): KeyAndValueAsBufferIterator; + destroy(location: string, callback: ErrCallback): void; + repair(location: string, callback: ErrCallback): void; +} + +type Constructor = (location: string) => LevelDown; +} diff --git a/types/leveldown/leveldown-tests.ts b/types/leveldown/leveldown-tests.ts new file mode 100644 index 0000000000..f627f422f5 --- /dev/null +++ b/types/leveldown/leveldown-tests.ts @@ -0,0 +1,86 @@ +import * as leveldown from "leveldown"; + +let db = leveldown("db1"); + +db.open((err) => {}); +db.open({createIfMissing: true}, (err) => {}); + +db.put("key", "value", (err) => {}); +db.put(Buffer.from("key"), Buffer.from("value"), (err) => {}); +db.put("key", "value", {sync: true}, (err) => {}); + +db.get("key", {asBuffer: false}, (error, val) => { + console.log(val.toUpperCase()); +}); +db.get("key", {fillCache: true}, (error, val) => { + console.log(val.readUInt32BE(0)); +}); +db.get("key", (error, val) => { + console.log(val.readUInt32BE(0)); +}); + +db.del("key"); +db.del("key", (error) => {}); +db.del("key", {sync: true}, (error) => {}); + +db.batch([{ + type: "put", key: "k", value: "v" +}, { + type: "del", key: "k" +}], (error) => {}); + +const keyAsStringIterator = db.iterator({keyAsBuffer: false}); +keyAsStringIterator.next((err, k, v) => { + console.log(k.toUpperCase()); + console.log(v.readUInt32BE(0)); +}); + +const valueAsStringIterator = db.iterator({valueAsBuffer: false}); +valueAsStringIterator.next((err, k, v) => { + console.log(k.readUInt32BE(0)); + console.log(v.toUpperCase()); +}); + +const keyAndValueAsStringIterator = db.iterator({keyAsBuffer: false, valueAsBuffer: false}); +keyAndValueAsStringIterator.next((err, k, v) => { + console.log(k.toUpperCase()); + console.log(v.toUpperCase()); +}); + +const keyAndValueAsBufferIterator1 = db.iterator({keyAsBuffer: true, valueAsBuffer: true}); +keyAndValueAsBufferIterator1.next((err, k, v) => { + console.log(k.readUInt32BE(0)); + console.log(v.readUInt32BE(0)); +}); + +const keyAndValueAsBufferIterator2 = db.iterator({keyAsBuffer: true}); +keyAndValueAsBufferIterator2.next((err, k, v) => { + console.log(k.readUInt32BE(0)); + console.log(v.readUInt32BE(0)); +}); + +const keyAndValueAsBufferIterator3 = db.iterator({valueAsBuffer: true}); +keyAndValueAsBufferIterator3.next((err, k, v) => { + console.log(k.readUInt32BE(0)); + console.log(v.readUInt32BE(0)); +}); + +const keyAndValueAsBufferIterator4 = db.iterator({}); +keyAndValueAsBufferIterator4.next((err, k, v) => { + console.log(k.readUInt32BE(0)); + console.log(v.readUInt32BE(0)); +}); + +keyAndValueAsBufferIterator4.seek("k"); +keyAndValueAsBufferIterator4.end((err) => {}); + +let s: string = db.getProperty("leveldb.stats"); + +db.approximateSize("k1", "k2", (err, size) => { + console.log(size.toExponential()); +}); + +db.compactRange("k1", "k2", (err) => {}); + +db.destroy("/path/to/db", (err) => {}); +db.repair("/path/to/db", (err) => {}); diff --git a/types/leveldown/tsconfig.json b/types/leveldown/tsconfig.json new file mode 100644 index 0000000000..c69d58061a --- /dev/null +++ b/types/leveldown/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "leveldown-tests.ts" + ] +} diff --git a/types/leveldown/tslint.json b/types/leveldown/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leveldown/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/levelup/index.d.ts b/types/levelup/index.d.ts index b78d2e6e5a..69c816638b 100644 --- a/types/levelup/index.d.ts +++ b/types/levelup/index.d.ts @@ -5,6 +5,14 @@ /// +import * as leveldown from "leveldown"; + +export = levelup; + +declare var levelup: levelup.LevelUpConstructor; + +declare namespace levelup { + interface CustomEncoding { encode(val: any): Buffer| string; decode(val: Buffer | string): any; @@ -21,7 +29,8 @@ interface Batch { keyEncoding?: Encoding; valueEncoding?: Encoding; } -interface LevelUp { + +interface LevelUpBase { open(callback ?: (error : any) => any): void; close(callback ?: (error : any) => any): void; put(key: any, value: any, callback ?: (error: any) => any): void; @@ -33,8 +42,8 @@ interface LevelUp { del(key: any, options ?: { keyEncoding?: Encoding; sync?: boolean }, callback ?: (error: any) => any): void; - batch(array: Batch[], options?: { keyEncoding?: Encoding; valueEncoding?: Encoding; sync?: boolean }, callback?: (error?: any)=>any): void; - batch(array: Batch[], callback?: (error?: any)=>any): void; + batch(array: BatchType[], options?: { keyEncoding?: Encoding; valueEncoding?: Encoding; sync?: boolean }, callback?: (error?: any)=>any): void; + batch(array: BatchType[], callback?: (error?: any)=>any): void; batch():LevelUpChain; isOpen():boolean; isClosed():boolean; @@ -46,6 +55,8 @@ interface LevelUp { repair(location: string, callback?: Function): void; } +type LevelUp = LevelUpBase + interface LevelUpChain { put(key: any, value: any): LevelUpChain; put(key: any, value: any, options?: { sync?: boolean }): LevelUpChain; @@ -62,18 +73,10 @@ interface levelupOptions { cacheSize?: number; keyEncoding?: Encoding; valueEncoding?: Encoding; - db?: string + db?: leveldown.Constructor; } -declare module "levelup" { - - function levelup(hostname: string, options?: levelupOptions): LevelUp; - - export = levelup; +interface LevelUpConstructor { + (hostname: string, options?: levelupOptions): LevelUp; } - -declare module "leveldown" { - - export function destroy(location: string, callback?: Function): void; - export function repair(location: string, callback?: Function): void; } diff --git a/types/levelup/levelup-tests.ts b/types/levelup/levelup-tests.ts index 57eea64e63..8827512437 100644 --- a/types/levelup/levelup-tests.ts +++ b/types/levelup/levelup-tests.ts @@ -1,4 +1,4 @@ -import levelup = require("levelup"); +import * as levelup from "levelup"; interface BufferEncoding { encode(val: any): Buffer; @@ -82,7 +82,3 @@ db.createReadStream() .on('end', function () { console.log('Stream closed') }) - -import leveldown = require('leveldown'); -leveldown.destroy('mypath', ()=>{}); -leveldown.repair('mypath', ()=>{}); From bcf1928b97085296967dfd07f11011b05ec2fc75 Mon Sep 17 00:00:00 2001 From: Mustafa Kuscu Date: Fri, 5 May 2017 04:16:03 +0300 Subject: [PATCH 20/50] update leaflet fullscreen type definitons (#16106) L.Control.Fullscreen was not found. --- types/leaflet.fullscreen/index.d.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/types/leaflet.fullscreen/index.d.ts b/types/leaflet.fullscreen/index.d.ts index 67af1d6770..e38890b2d8 100644 --- a/types/leaflet.fullscreen/index.d.ts +++ b/types/leaflet.fullscreen/index.d.ts @@ -9,24 +9,27 @@ declare namespace L { namespace Control { - export interface Fullscreen extends L.Control {} - + export class Fullscreen extends L.Control { + constructor(options?: Control.FullscreenOptions); + options: FullscreenOptions; + } export interface FullscreenOptions { content?: string, - position?: string, - title?: string, - titleCancel?: string, - forceSeparateButton?: boolean, - forcePseudoFullscreen?: boolean + position?: L.ControlPosition, + title?: string, + titleCancel?: string, + forceSeparateButton?: boolean, + forcePseudoFullscreen?: boolean, + pseudoFullscreen?:boolean } } namespace control { - /** - * Creates a fullscreen control. - */ - export function fullscreen(options?: Control.FullscreenOptions): L.Control.Fullscreen; + /** + * Creates a fullscreen control. + */ + export function fullscreen(options?: Control.FullscreenOptions): L.Control.Fullscreen; } } From 34379212072e8b73af27a90622f74a70f7329303 Mon Sep 17 00:00:00 2001 From: Jelle Slowack Date: Fri, 5 May 2017 03:18:01 +0200 Subject: [PATCH 21/50] fabric: callback and options object is optional in setSrc method (#16101) * callback and options object is optional in setSrc method * run tsc fixes, remove deprecated internal modules and HtmlInputElement casts --- types/fabric/fabric-tests.ts | 41 ++++++++++++++++++------------------ types/fabric/index.d.ts | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/types/fabric/fabric-tests.ts b/types/fabric/fabric-tests.ts index 62c0726e16..770467590c 100644 --- a/types/fabric/fabric-tests.ts +++ b/types/fabric/fabric-tests.ts @@ -1,5 +1,3 @@ -import * as fabric from "fabric"; - function sample1() { const canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', @@ -124,11 +122,12 @@ function sample3() { } }); - fabric.Image.fromURL('../assets/printio.png', img => { + const image = fabric.Image.fromURL('../assets/printio.png', img => { const oImg = img.set({ left: 300, top: 300, angle: -15 }).scale(0.9); canvas.add(oImg).renderAll(); canvas.setActiveObject(oImg); }); + image.setSrc('../assets/printio.png'); $('grayscale').onclick = function(this: HTMLInputElement) { applyFilter(0, this.checked && new f.Grayscale()); @@ -260,18 +259,18 @@ function sample4() { }); } -declare module "fabric" { - export interface CircleWithLineInfos extends Circle { - line1?: Line; - line2?: Line; - line3?: Line; - line4?: Line; +namespace myfabric { + export interface CircleWithLineInfos extends fabric.Circle { + line1?: fabric.Line; + line2?: fabric.Line; + line3?: fabric.Line; + line4?: fabric.Line; } } function sample5() { const makeCircle = (left: number, top: number, line1?: fabric.Line, line2?: fabric.Line, line3?: fabric.Line, line4?: fabric.Line): fabric.Circle => { - const c = new fabric.Circle({ + const c = new fabric.Circle({ left, top, strokeWidth: 5, @@ -318,7 +317,7 @@ function sample5() { ); canvas.on('object:moving', e => { - const p = e.target; + const p = e.target; p.line1 && p.line1.set({ 'x2': p.left, 'y2': p.top }); p.line2 && p.line2.set({ 'x1': p.left, 'y1': p.top }); p.line3 && p.line3.set({ 'x1': p.left, 'y1': p.top }); @@ -352,8 +351,8 @@ function sample6() { }); } -declare module "fabric" { - export interface ImageWithInfo extends Image { +namespace myfabric { + export interface ImageWithInfo extends fabric.Image { movingLeft: boolean; } } @@ -363,7 +362,7 @@ function sample7() { setInterval(() => { fabric.Image.fromURL('../assets/ladybug.png', obj => { - const img = obj; + const img = obj; img.set('left', fabric.util.getRandomInt(200, 600)).set('top', -50); img.movingLeft = !!Math.round(Math.random()); canvas.add(img); @@ -372,7 +371,7 @@ function sample7() { const animate = (function animate() { canvas.forEachObject(obj => { - const img = obj; + const img = obj; img.left += (img.movingLeft ? -1 : 1); img.top += 1; if (img.left > 900 || img.top > 500) { @@ -609,7 +608,7 @@ function sample8() { const activeGroup = canvas.getActiveGroup(); if (activeObject || activeGroup) { - (activeObject || activeGroup).setOpacity(parseInt(this.value, 10) / 100); + (activeObject || activeGroup).setOpacity(parseInt(( this).value, 10) / 100); canvas.renderAll(); } }; @@ -640,7 +639,7 @@ function sample8() { const activeGroup = canvas.getActiveGroup(); if (activeObject || activeGroup) { - (activeObject || activeGroup).setFill(this.value); + (activeObject || activeGroup).setFill(( this).value); canvas.renderAll(); } }; @@ -849,16 +848,16 @@ function sample8() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - this.value = ( activeObject).text; + ( this).value = ( activeObject).text; } }; textEl.onkeyup = function(e) { const activeObject = canvas.getActiveObject(); if (activeObject) { - if (!this.value) { + if (!( this).value) { canvas.discardActiveObject(); } else { - ( activeObject).text = this.value; + ( activeObject).text = ( this).value; } canvas.renderAll(); } @@ -1006,7 +1005,7 @@ function sample8() { slider.onchange = function() { const activeObject = canvas.getActiveObject(); if (activeObject && activeObject.type === 'text') { - activeObject.lineHeight = +this.value; + activeObject.lineHeight = +( this).value; canvas.renderAll(); } }; diff --git a/types/fabric/index.d.ts b/types/fabric/index.d.ts index ca99080bad..1596d7d428 100644 --- a/types/fabric/index.d.ts +++ b/types/fabric/index.d.ts @@ -1866,7 +1866,7 @@ export class Image { * @param {Function} [callback] Callback is invoked when image has been loaded (and all filters have been applied) * @param {Object} [options] Options object */ - setSrc(src: string, callback: Function, options: IImageOptions): Image; + setSrc(src: string, callback?: Function, options?: IImageOptions): Image; /** * Creates an instance of fabric.Image from an URL string From c223230018708c8ee6fd9e1871801ed0106502c2 Mon Sep 17 00:00:00 2001 From: Maxim Kulikov Date: Fri, 5 May 2017 04:18:34 +0300 Subject: [PATCH 22/50] jquery: allow propertyNames array to `css()` (#16093) --- types/jquery/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/jquery/index.d.ts b/types/jquery/index.d.ts index f944f93ba3..80db74ee9f 100644 --- a/types/jquery/index.d.ts +++ b/types/jquery/index.d.ts @@ -1657,6 +1657,14 @@ interface JQuery { * @see {@link https://api.jquery.com/css/#css-propertyName} */ css(propertyName: string): string; + /** + * Get the value of style properties for the first element in the set of matched elements. + * Results in an object of property-value pairs. + * + * @param propertyNames An array of one or more CSS properties. + * @see {@link https://api.jquery.com/css/#css-propertyNames} + */ + css(propertyNames: string[]): any; /** * Set one or more CSS properties for the set of matched elements. * From 407cace6b4699056e27c50cfdb9379277b66303b Mon Sep 17 00:00:00 2001 From: apollocoder Date: Fri, 5 May 2017 03:19:11 +0200 Subject: [PATCH 23/50] Update index.d.ts (#16119) Added missing restore option --- types/cropperjs/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/cropperjs/index.d.ts b/types/cropperjs/index.d.ts index 89d35ed998..a82fa718f9 100644 --- a/types/cropperjs/index.d.ts +++ b/types/cropperjs/index.d.ts @@ -131,6 +131,11 @@ declare namespace cropperjs { */ rotatable?: boolean; /** + * Enable to restore the cropped area after resizing the window. + * @default true + */ + restore?: boolean; + /** * Enable to scale the image. * @default true */ From fef536fb657aa0e697e730f39907ab8261316209 Mon Sep 17 00:00:00 2001 From: Jayden Zhao Date: Fri, 5 May 2017 23:53:29 +0800 Subject: [PATCH 24/50] Add types/react-native-goby/* (#16312) * add react-native-goby * add react-native-goby * add react-native-goby * remove the Promise define of types/react-native-goby --- types/react-native-goby/index.d.ts | 410 ++++++++++++++++++ .../react-native-goby-tests.tsx | 23 + types/react-native-goby/tsconfig.json | 23 + types/react-native-goby/tslint.json | 22 + 4 files changed, 478 insertions(+) create mode 100644 types/react-native-goby/index.d.ts create mode 100644 types/react-native-goby/react-native-goby-tests.tsx create mode 100644 types/react-native-goby/tsconfig.json create mode 100644 types/react-native-goby/tslint.json diff --git a/types/react-native-goby/index.d.ts b/types/react-native-goby/index.d.ts new file mode 100644 index 0000000000..c89cc7b065 --- /dev/null +++ b/types/react-native-goby/index.d.ts @@ -0,0 +1,410 @@ +// Type definitions for react-native-goby 0.04 +// Project: https://gitlab.com/MessageDream/react-native-goby +// Definitions by: jaydenzhao +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export type DownloadProgressCallback = (progress: DownloadProgress) => void; +export type SyncStatusChangedCallback = (status: Goby.SyncStatus) => void; + +export interface GobyOptions extends SyncOptions { + /** + * Specifies when you would like to synchronize updates with the Goby server. + * Defaults to goby.CheckFrequency.ON_APP_START. + */ + checkFrequency: Goby.CheckFrequency; +} + +export interface DownloadProgress { + /** + * The total number of bytes expected to be received for this update. + */ + totalBytes: number; + + /** + * The number of bytes downloaded thus far. + */ + receivedBytes: number; +} + +export interface LocalPackage extends Package { + /** + * Installs the update by saving it to the location on disk where the runtime expects to find the latest version of the app. + * + * @param installMode Indicates when you would like the update changes to take affect for the end-user. + * @param minimumBackgroundDuration For resume-based installs, this specifies the number of seconds the app needs to be in the background before forcing a restart. Defaults to 0 if unspecified. + */ + install(installMode: Goby.InstallMode, minimumBackgroundDuration?: number): Promise; +} + +export interface Package { + /** + * The app binary version that this update is dependent on. This is the value that was + * specified via the appStoreVersion parameter when calling the CLI's release command. + */ + appVersion: string; + + /** + * The deployment key that was used to originally download this update. + */ + deploymentKey: string; + + /** + * The description of the update. This is the same value that you specified in the CLI when you released the update. + */ + description: string; + + /** + * Indicates whether this update has been previously installed but was rolled back. + */ + failedInstall: boolean; + + /** + * Indicates whether this is the first time the update has been run after being installed. + */ + isFirstRun: boolean; + + /** + * Indicates whether the update is considered mandatory. This is the value that was specified in the CLI when the update was released. + */ + isMandatory: boolean; + + /** + * Indicates whether this update is in a "pending" state. When true, that means the update has been downloaded and installed, but the app restart + * needed to apply it hasn't occurred yet, and therefore, its changes aren't currently visible to the end-user. + */ + isPending: boolean; + + /** + * The internal label automatically given to the update by the Goby server. This value uniquely identifies the update within its deployment. + */ + label: string; + + /** + * The SHA hash value of the update. + */ + packageHash: string; + + /** + * The size of the code contained within the update, in bytes. + */ + packageSize: number; +} + +export interface RemotePackage extends Package { + /** + * Downloads the available update from the Goby service. + * + * @param downloadProgressCallback An optional callback that allows tracking the progress of the update while it is being downloaded. + */ + download(downloadProgressCallback?: DownloadProgressCallback): Promise; + + /** + * The URL at which the package is available for download. + */ + downloadUrl: string; +} + +export interface SyncOptions { + /** + * Specifies the deployment key you want to query for an update against. By default, this value is derived from the Info.plist + * file (iOS) and MainActivity.java file (Android), but this option allows you to override it from the script-side if you need to + * dynamically use a different deployment for a specific call to sync. + */ + deploymentKey?: string; + + /** + * Specifies when you would like to install optional updates (i.e. those that aren't marked as mandatory). + * Defaults to goby.InstallMode.ON_NEXT_RESTART. + */ + installMode?: Goby.InstallMode; + + /** + * Specifies when you would like to install updates which are marked as mandatory. + * Defaults to goby.InstallMode.IMMEDIATE. + */ + mandatoryInstallMode?: Goby.InstallMode; + + /** + * Specifies the minimum number of seconds that the app needs to have been in the background before restarting the app. This property + * only applies to updates which are installed using `InstallMode.ON_NEXT_RESUME`, and can be useful for getting your update in front + * of end users sooner, without being too obtrusive. Defaults to `0`, which has the effect of applying the update immediately after a + * resume, regardless how long it was in the background. + */ + minimumBackgroundDuration?: number; + + /** + * An "options" object used to determine whether a confirmation dialog should be displayed to the end user when an update is available, + * and if so, what strings to use. Defaults to null, which has the effect of disabling the dialog completely. Setting this to any truthy + * value will enable the dialog with the default strings, and passing an object to this parameter allows enabling the dialog as well as + * overriding one or more of the default strings. + */ + updateDialog?: UpdateDialog; +} + +export interface UpdateDialog { + /** + * Indicates whether you would like to append the description of an available release to the + * notification message which is displayed to the end user. Defaults to false. + */ + appendReleaseDescription?: boolean; + + /** + * Indicates the string you would like to prefix the release description with, if any, when + * displaying the update notification to the end user. Defaults to " Description: " + */ + descriptionPrefix?: string; + + /** + * The text to use for the button the end user must press in order to install a mandatory update. Defaults to "Continue". + */ + mandatoryContinueButtonLabel?: string; + + /** + * The text used as the body of an update notification, when the update is specified as mandatory. + * Defaults to "An update is available that must be installed.". + */ + mandatoryUpdateMessage?: string; + + /** + * The text to use for the button the end user can press in order to ignore an optional update that is available. Defaults to "Ignore". + */ + optionalIgnoreButtonLabel?: string; + + /** + * The text to use for the button the end user can press in order to install an optional update. Defaults to "Install". + */ + optionalInstallButtonLabel?: string; + + /** + * The text used as the body of an update notification, when the update is optional. Defaults to "An update is available. Would you like to install it?". + */ + optionalUpdateMessage?: string; + + /** + * The text used as the header of an update notification that is displayed to the end user. Defaults to "Update available". + */ + title?: string; +} + +export interface StatusReport { + /** + * Whether the deployment succeeded or failed. + */ + status: Goby.DeploymentStatus; + + /** + * The version of the app that was deployed (for a native app upgrade). + */ + appVersion?: string; + + /** + * Details of the package that was deployed (or attempted to). + */ + package?: Package; + + /** + * Deployment key used when deploying the previous package. + */ + previousDeploymentKey?: string; + + /** + * The label (v#) of the package that was upgraded from. + */ + previousLabelOrAppVersion?: string; +} + +/** + * Decorates a React Component configuring it to sync for updates with the Goby server. + * + * @param options Options used to configure the end-user sync and update experience (e.g. when to check for updates?, show an prompt?, install the update immediately?). + */ +declare function Goby(options?: GobyOptions): Function; + +declare namespace Goby { + /** + * Represents the default settings that will be used by the sync method if + * an update dialog is configured to be displayed. + */ + var DEFAULT_UPDATE_DIALOG: UpdateDialog; + + /** + * Asks the Goby service whether the configured app deployment has an update available. + * + * @param deploymentKey The deployment key to use to query the Goby server for an update. + */ + function checkForUpdate(deploymentKey?: string): Promise; + + /** + * Retrieves the metadata for an installed update (e.g. description, mandatory). + * + * @param updateState The state of the update you want to retrieve the metadata for. Defaults to UpdateState.RUNNING. + */ + function getUpdateMetadata(updateState?: UpdateState): Promise; + + /** + * Notifies the Goby runtime that an installed update is considered successful. + */ + function notifyAppReady(): Promise; + + /** + * Allow Goby to restart the app. + */ + function allowRestart(): void; + + /** + * Forbid Goby to restart the app. + */ + function disallowRestart(): void; + + /** + * Immediately restarts the app. + * + * @param onlyIfUpdateIsPending Indicates whether you want the restart to no-op if there isn't currently a pending update. + */ + function restartApp(onlyIfUpdateIsPending?: boolean): void; + + /** + * Allows checking for an update, downloading it and installing it, all with a single call. + * + * @param options Options used to configure the end-user update experience (e.g. show an prompt?, install the update immediately?). + * @param syncStatusChangedCallback An optional callback that allows tracking the status of the sync operation, as opposed to simply checking the resolved state via the returned Promise. + * @param downloadProgressCallback An optional callback that allows tracking the progress of an update while it is being downloaded. + */ + function sync(options?: SyncOptions, syncStatusChangedCallback?: SyncStatusChangedCallback, downloadProgressCallback?: DownloadProgressCallback): Promise; + + /** + * Indicates when you would like an installed update to actually be applied. + */ + enum InstallMode { + /** + * Indicates that you want to install the update and restart the app immediately. + */ + IMMEDIATE, + + /** + * Indicates that you want to install the update, but not forcibly restart the app. + */ + ON_NEXT_RESTART, + + /** + * Indicates that you want to install the update, but don't want to restart the + * app until the next time the end user resumes it from the background. + */ + ON_NEXT_RESUME + } + + /** + * Indicates the current status of a sync operation. + */ + enum SyncStatus { + /** + * The Goby server is being queried for an update. + */ + CHECKING_FOR_UPDATE, + + /** + * An update is available, and a confirmation dialog was shown + * to the end user. (This is only applicable when the updateDialog is used) + */ + AWAITING_USER_ACTION, + + /** + * An available update is being downloaded from the Goby server. + */ + DOWNLOADING_PACKAGE, + + /** + * An available update was downloaded and is about to be installed. + */ + INSTALLING_UPDATE, + + /** + * The app is up-to-date with the Goby server. + */ + UP_TO_DATE, + + /** + * The app had an optional update which the end user chose to ignore. + * (This is only applicable when the updateDialog is used) + */ + UPDATE_IGNORED, + + /** + * An available update has been installed and will be run either immediately after the + * syncStatusChangedCallback function returns or the next time the app resumes/restarts, + * depending on the InstallMode specified in SyncOptions + */ + UPDATE_INSTALLED, + + /** + * There is an ongoing sync operation running which prevents the current call from being executed. + */ + SYNC_IN_PROGRESS, + + /** + * The sync operation encountered an unknown error. + */ + UNKNOWN_ERROR + } + + /** + * Indicates the state that an update is currently in. + */ + enum UpdateState { + /** + * Indicates that an update represents the + * version of the app that is currently running. + */ + RUNNING, + + /** + * Indicates than an update has been installed, but the + * app hasn't been restarted yet in order to apply it. + */ + PENDING, + + /** + * Indicates than an update represents the latest available + * release, and can be either currently running or pending. + */ + LATEST + } + + /** + * Indicates the status of a deployment (after installing and restarting). + */ + enum DeploymentStatus { + /** + * The deployment failed (and was rolled back). + */ + FAILED, + + /** + * The deployment succeeded. + */ + SUCCEEDED + } + + /** + * Indicates when you would like to check for (and install) updates from the Goby server. + */ + enum CheckFrequency { + /** + * When the app is fully initialized (or more specifically, when the root component is mounted). + */ + ON_APP_START, + + /** + * When the app re-enters the foreground. + */ + ON_APP_RESUME, + + /** + * Don't automatically check for updates, but only do it when goby.sync() is manully called inside app code. + */ + MANUAL + } +} + +export default Goby; diff --git a/types/react-native-goby/react-native-goby-tests.tsx b/types/react-native-goby/react-native-goby-tests.tsx new file mode 100644 index 0000000000..6c8ed6737b --- /dev/null +++ b/types/react-native-goby/react-native-goby-tests.tsx @@ -0,0 +1,23 @@ +import * as React from 'react'; + +import { + View, + AppRegistry +} from 'react-native'; + +import Goby from "react-native-goby"; + +class Home extends React.Component { + render() { + return ( + + ); + } +} + + +AppRegistry.registerComponent('home', () => Goby({ + updateDialog: false, + checkFrequency: Goby.CheckFrequency.ON_APP_RESUME, + installMode: Goby.InstallMode.IMMEDIATE +})(Home)); diff --git a/types/react-native-goby/tsconfig.json b/types/react-native-goby/tsconfig.json new file mode 100644 index 0000000000..fa2d947691 --- /dev/null +++ b/types/react-native-goby/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-native-goby-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/react-native-goby/tslint.json b/types/react-native-goby/tslint.json new file mode 100644 index 0000000000..d774391cd1 --- /dev/null +++ b/types/react-native-goby/tslint.json @@ -0,0 +1,22 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // Lowercase `object` is available in TypeScript 2.2 only. + "ban-types": false, + // Below are all TODO + "align": false, + "array-type": false, + "comment-format": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "no-misused-new": false, + "no-consecutive-blank-lines": false, + "no-empty-interface": false, + "no-padding": false, + "no-var": false, + "prefer-declare-function": false, + "prefer-method-signature": false, + "semicolon": false, + "strict-export-declare-modifiers": false + } +} From 11b7768836b6516f4ab4a099724f7c9fb946b97a Mon Sep 17 00:00:00 2001 From: Takeshi Kurosawa Date: Sat, 6 May 2017 00:54:50 +0900 Subject: [PATCH 25/50] diff: add support options parameter of diffLines (#16333) * diff: add support options parameter of diffLines The options parameter is described at https://github.com/kpdecker/jsdiff/blob/master/README.md * diff: add tslint.json and fix lint issues --- types/diff/diff-tests.ts | 16 +++++++-------- types/diff/index.d.ts | 44 ++++++++++++++++++++++------------------ types/diff/tslint.json | 7 +++++++ 3 files changed, 38 insertions(+), 29 deletions(-) create mode 100644 types/diff/tslint.json diff --git a/types/diff/diff-tests.ts b/types/diff/diff-tests.ts index 36edef83b3..e1b1025495 100644 --- a/types/diff/diff-tests.ts +++ b/types/diff/diff-tests.ts @@ -1,13 +1,11 @@ - - +// tslint:disable:no-var only-arrow-functions import jsdiff = require('diff'); - var one = 'beep boop'; var other = 'beep boob blah'; var diff = jsdiff.diffChars(one, other); -diff.forEach(function (part) { +diff.forEach(function(part) { var mark = part.added ? '+' : part.removed ? '-' : ' '; console.log(mark + " " + part.value); @@ -16,11 +14,11 @@ diff.forEach(function (part) { // -------------------------- class LineDiffWithoutWhitespace extends jsdiff.Diff { - tokenize(value:string):any { + tokenize(value: string): any { return value.split(/^/m); } - equals(left:string, right:string):boolean { + equals(left: string, right: string): boolean { return left.trim() === right.trim(); } } @@ -29,8 +27,8 @@ var obj = new LineDiffWithoutWhitespace(true); var diff = obj.diff(one, other); printDiff(diff); -function printDiff(diff:jsdiff.IDiffResult[]) { - function addLineHeader(decorator:string, str:string) { +function printDiff(diff: jsdiff.IDiffResult[]) { + function addLineHeader(decorator: string, str: string) { return str.split("\n").map((line, index, array) => { if (index === array.length - 1 && line === "") { return line; @@ -40,7 +38,7 @@ function printDiff(diff:jsdiff.IDiffResult[]) { }).join("\n"); } - diff.forEach((part)=> { + diff.forEach((part) => { if (part.added) { console.log(addLineHeader("+", part.value)); } else if (part.removed) { diff --git a/types/diff/index.d.ts b/types/diff/index.d.ts index 102305ce70..03228269e0 100644 --- a/types/diff/index.d.ts +++ b/types/diff/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for diff +// Type definitions for diff 3.2 // Project: https://github.com/kpdecker/jsdiff // Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export = JsDiff; export as namespace JsDiff; @@ -36,34 +37,37 @@ declare namespace JsDiff { } class Diff { - ignoreWhitespace:boolean; + ignoreWhitespace: boolean; - constructor(ignoreWhitespace?:boolean); + constructor(ignoreWhitespace?: boolean); - diff(oldString:string, newString:string):IDiffResult[]; + diff(oldString: string, newString: string): IDiffResult[]; - pushComponent(components:IDiffResult[], value:string, added:boolean, removed:boolean):void; + pushComponent(components: IDiffResult[], value: string, added: boolean, removed: boolean): void; - extractCommon(basePath:IBestPath, newString:string, oldString:string, diagonalPath:number):number; + extractCommon(basePath: IBestPath, newString: string, oldString: string, diagonalPath: number): number; - equals(left:string, right:string):boolean; + equals(left: string, right: string): boolean; - join(left:string, right:string):string; + join(left: string, right: string): string; - tokenize(value:string):any; // return types are string or string[] + tokenize(value: string): any; // return types are string or string[] } - function diffChars(oldStr:string, newStr:string):IDiffResult[]; + function diffChars(oldStr: string, newStr: string): IDiffResult[]; - function diffWords(oldStr:string, newStr:string):IDiffResult[]; + function diffWords(oldStr: string, newStr: string): IDiffResult[]; - function diffWordsWithSpace(oldStr:string, newStr:string):IDiffResult[]; + function diffWordsWithSpace(oldStr: string, newStr: string): IDiffResult[]; - function diffJson(oldObj: Object, newObj: Object): IDiffResult[]; + function diffJson(oldObj: object, newObj: object): IDiffResult[]; - function diffLines(oldStr:string, newStr:string):IDiffResult[]; + function diffLines(oldStr: string, newStr: string, options?: { + ignoreWhitespace?: boolean, + newlineIsToken?: boolean, + }): IDiffResult[]; - function diffCss(oldStr:string, newStr:string):IDiffResult[]; + function diffCss(oldStr: string, newStr: string): IDiffResult[]; function createPatch(fileName: string, oldStr: string, newStr: string, oldHeader: string, newHeader: string, options?: {context: number}): string; @@ -74,14 +78,14 @@ declare namespace JsDiff { function applyPatch(oldStr: string, uniDiff: string | IUniDiff | IUniDiff[]): string; function applyPatches(uniDiff: IUniDiff[], options: { - loadFile: (index: number, callback: (err: Error, data: string) => void) => void, - patched: (index: number, content: string) => void, - complete: (err?: Error) => void + loadFile(index: number, callback: (err: Error, data: string) => void): void, + patched(index: number, content: string): void, + complete(err?: Error): void }): void; function parsePatch(diffStr: string, options?: {strict: boolean}): IUniDiff[]; - function convertChangesToXML(changes:IDiffResult[]):string; + function convertChangesToXML(changes: IDiffResult[]): string; - function convertChangesToDMP(changes:IDiffResult[]):{0: number; 1:string;}[]; + function convertChangesToDMP(changes: IDiffResult[]): Array<{0: number; 1: string; }>; } diff --git a/types/diff/tslint.json b/types/diff/tslint.json new file mode 100644 index 0000000000..1b7b2672e6 --- /dev/null +++ b/types/diff/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "interface-name": false, + "export-just-namespace": false + } +} From c4a2a2a97695102a0ddaf93a685434878414622e Mon Sep 17 00:00:00 2001 From: AJ Richardson Date: Fri, 5 May 2017 11:55:48 -0400 Subject: [PATCH 26/50] lodash: callback parameters should not be optional (#11516) (#15895) --- types/lodash/index.d.ts | 18 +- types/lodash/lodash-tests.ts | 1077 +++++++++++++++++----------------- types/lodash/tsconfig.json | 2 +- 3 files changed, 552 insertions(+), 545 deletions(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index 22b2d6b9e1..b8ae248190 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -18522,7 +18522,7 @@ declare namespace _ { * @param defaultValue The default value. * @returns Returns the resolved value. */ - defaultTo(value: T, defaultValue: T): T; + defaultTo(value: T | null | undefined, defaultValue: T): T; } interface LoDashImplicitWrapperBase { @@ -19591,20 +19591,20 @@ declare namespace _ { type ListIterator = (value: T, index: number, collection: List) => TResult; - type DictionaryIterator = (value: T, key?: string, collection?: Dictionary) => TResult; + type DictionaryIterator = (value: T, key: string, collection: Dictionary) => TResult; - type NumericDictionaryIterator = (value: T, key?: number, collection?: Dictionary) => TResult; + type NumericDictionaryIterator = (value: T, key: number, collection: Dictionary) => TResult; - type ObjectIterator = (element: T, key?: string, collection?: any) => TResult; + type ObjectIterator = (element: T, key: string, collection: any) => TResult; - type StringIterator = (char: string, index?: number, string?: string) => TResult; + type StringIterator = (char: string, index: number, string: string) => TResult; - type MemoVoidIterator = (prev: TResult, curr: T, indexOrKey?: any, list?: T[]) => void; + type MemoVoidIterator = (prev: TResult, curr: T, indexOrKey: any, list: T[]) => void; - type MemoIterator = (prev: TResult, curr: T, indexOrKey?: any, list?: T[]) => TResult; + type MemoIterator = (prev: TResult, curr: T, indexOrKey: any, list: T[]) => TResult; - type MemoVoidArrayIterator = (acc: TResult, curr: T, index?: number, arr?: T[]) => void; - type MemoVoidDictionaryIterator = (acc: TResult, curr: T, key?: string, dict?: Dictionary) => void; + type MemoVoidArrayIterator = (acc: TResult, curr: T, index: number, arr: T[]) => void; + type MemoVoidDictionaryIterator = (acc: TResult, curr: T, key: string, dict: Dictionary) => void; // Common interface between Arrays and jQuery objects interface List { diff --git a/types/lodash/lodash-tests.ts b/types/lodash/lodash-tests.ts index af30a416d6..4f479eab83 100644 --- a/types/lodash/lodash-tests.ts +++ b/types/lodash/lodash-tests.ts @@ -96,7 +96,12 @@ interface TResult { } // _.MapCache -let testMapCache: _.MapCache; +let testMapCache: _.MapCache = { + delete(key: string) { return true; }, + get(key: string): any { return 1; }, + has(key: string) { return true; }, + set(key: string, value: any): _.Dictionary { return {}; }, +}; result = <(key: string) => boolean>testMapCache.delete; result = <(key: string) => any>testMapCache.get; result = <(key: string) => boolean>testMapCache.has; @@ -153,8 +158,8 @@ result = <_.LoDashExplicitArrayWrapper>_.chain([1, 2, 3, 4]).unshift(5, // _.chunk namespace TestChunk { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[][]; @@ -189,8 +194,8 @@ namespace TestChunk { // _.compact namespace TestCompact { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -217,8 +222,8 @@ namespace TestCompact { // _.difference namespace TestDifference { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -265,9 +270,9 @@ namespace TestDifference { // _.differenceBy namespace TestDifferenceBy { - let array: TResult[]; - let list: _.List; - let iteratee: (value: TResult) => any; + let array: TResult[] = []; + let list: _.List = []; + let iteratee: (value: TResult) => any = (value: TResult) => 1; { let result: TResult[]; @@ -452,8 +457,8 @@ namespace TestDifferenceBy { // _.drop { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -487,8 +492,8 @@ namespace TestDifferenceBy { // _.dropRight namespace TestDropRight { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -523,9 +528,9 @@ namespace TestDropRight { // _.dropRightWhile namespace TestDropRightWhile { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; { let result: TResult[]; @@ -572,9 +577,9 @@ namespace TestDropRightWhile { // _.dropWhile namespace TestDropWhile { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; { let result: TResult[]; @@ -621,8 +626,8 @@ namespace TestDropWhile { // _.fill namespace TestFill { - let array: number[]; - let list: _.List; + let array: number[] = []; + let list: _.List = []; { let result: number[]; @@ -675,10 +680,10 @@ namespace TestFill { // _.findIndex namespace TestFindIndex { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; - let fromIndex: number; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; + let fromIndex: number = 0; { let result: number; @@ -727,11 +732,11 @@ namespace TestFindIndex { // _.findLastIndex namespace TestFindLastIndex { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; - let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; - let fromIndex: number; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; + let fromIndex: number = 0; { let result: number; @@ -780,8 +785,8 @@ namespace TestFindLastIndex { // _.first namespace TestFirst { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: string; @@ -992,8 +997,8 @@ namespace TestFlattenDeep { // _.fromPairs namespace TestFromPairs { - let twoDimensionalArray: string[][]; - let numberTupleArray: [string, number][]; + let twoDimensionalArray: string[][] = []; + let numberTupleArray: [string, number][] = []; let stringDict: _.Dictionary; let numberDict: _.Dictionary; @@ -1017,8 +1022,8 @@ namespace TestFromPairs { // _.head namespace TestHead { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: string; @@ -1053,9 +1058,9 @@ namespace TestHead { // _.indexOf namespace TestIndexOf { - let array: TResult[]; - let list: _.List; - let value: TResult; + let array: TResult[] = []; + let list: _.List = []; + let value: TResult = { a: 1, b: "", c: true }; { let result: number; @@ -1092,9 +1097,9 @@ namespace TestIndexOf { // _.sortedIndexOf namespace TestIndexOf { - let array: TResult[]; - let list: _.List; - let value: TResult; + let array: TResult[] = []; + let list: _.List = []; + let value: TResult = { a: 1, b: "", c: true }; { let result: number; @@ -1115,8 +1120,8 @@ namespace TestIndexOf { //_.initial namespace TestInitial { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1142,8 +1147,8 @@ namespace TestInitial { // _.intersection namespace TestIntersection { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1210,8 +1215,8 @@ namespace TestJoin { // _.last namespace TestLast { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: string; @@ -1251,9 +1256,9 @@ namespace TestLast { // _.lastIndexOf namespace TestLastIndexOf { - let array: TResult[]; - let list: _.List; - let value: TResult; + let array: TResult[] = []; + let list: _.List = []; + let value: TResult = { a: 1, b: "", c: true }; { let result: number; @@ -1290,9 +1295,9 @@ namespace TestLastIndexOf { // _.nth namespace TestNth { - let array: TResult[]; - let list: _.List; - let value: number; + let array: TResult[] = []; + let list: _.List = []; + let value: number = 0; { let result: TResult; @@ -1321,9 +1326,9 @@ namespace TestNth { // _.pull namespace TestPull { - let array: TResult[]; - let list: _.List; - let value: TResult; + let array: TResult[] = []; + let list: _.List = []; + let value: TResult = { a: 1, b: "", c: true }; { let result: TResult[]; @@ -1382,8 +1387,8 @@ namespace TestPull { // _.pullAt namespace TestPullAt { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1430,9 +1435,9 @@ namespace TestPullAt { // _.remove namespace TestRemove { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index?: number, collection?: _.List) => boolean; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; { let result: TResult[]; @@ -1479,8 +1484,8 @@ namespace TestRemove { // _.tail namespace TestTail { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1506,7 +1511,7 @@ namespace TestTail { // _.slice namespace TestSlice { - let array: TResult[]; + let array: TResult[] = []; { let result: TResult[]; @@ -1537,10 +1542,10 @@ namespace TestSlice { namespace TestSortedIndex { type SampleType = {a: number; b: string; c: boolean;}; - let array: SampleType[]; - let list: _.List; + let array: SampleType[] = []; + let list: _.List = []; - let value: SampleType; + let value: SampleType = { a: 1, b: "", c: true }; let stringIterator: (x: string) => number; let arrayIterator: (x: SampleType) => number; @@ -1577,14 +1582,14 @@ namespace TestSortedIndex { namespace TestSortedIndexBy { type SampleType = {a: number; b: string; c: boolean;}; - let array: SampleType[]; - let list: _.List; + let array: SampleType[] = []; + let list: _.List = []; - let value: SampleType; + let value: SampleType = { a: 1, b: "", c: true }; - let stringIterator: (x: string) => number; - let arrayIterator: (x: SampleType) => number; - let listIterator: (x: SampleType) => number; + let stringIterator = (x: string) => 0; + let arrayIterator = (x: SampleType) => 0; + let listIterator = (x: SampleType) => 0; { let result: number; @@ -1638,10 +1643,10 @@ namespace TestSortedIndexBy { namespace TestSortedLastIndex { type SampleType = {a: number; b: string; c: boolean;}; - let array: SampleType[]; - let list: _.List; + let array: SampleType[] = []; + let list: _.List = []; - let value: SampleType; + let value: SampleType = { a: 1, b: "", c: true }; let stringIterator: (x: string) => number; let arrayIterator: (x: SampleType) => number; @@ -1678,14 +1683,14 @@ namespace TestSortedLastIndex { namespace TestSortedLastIndexBy { type SampleType = {a: number; b: string; c: boolean;}; - let array: SampleType[]; - let list: _.List; + let array: SampleType[] = []; + let list: _.List = []; - let value: SampleType; + let value: SampleType = { a: 1, b: "", c: true }; - let stringIterator: (x: string) => number; - let arrayIterator: (x: SampleType) => number; - let listIterator: (x: SampleType) => number; + let stringIterator = (x: string) => 0; + let arrayIterator = (x: SampleType) => 0; + let listIterator = (x: SampleType) => 0; { let result: number; @@ -1737,8 +1742,8 @@ namespace TestSortedLastIndexBy { // _.tail namespace TestTail { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1764,8 +1769,8 @@ namespace TestTail { // _.take namespace TestTake { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1800,8 +1805,8 @@ namespace TestTake { // _.takeRight namespace TestTakeRight { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1836,9 +1841,9 @@ namespace TestTakeRight { // _.takeRightWhile namespace TestTakeRightWhile { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; { let result: TResult[]; @@ -1885,9 +1890,9 @@ namespace TestTakeRightWhile { // _.takeWhile namespace TestTakeWhile { - let array: TResult[]; - let list: _.List; - let predicateFn: (value: TResult, index: number, collection: _.List) => boolean; + let array: TResult[] = []; + let list: _.List = []; + let predicateFn = (value: TResult, index: number, collection: _.List) => true; { let result: TResult[]; @@ -1934,8 +1939,8 @@ namespace TestTakeWhile { // _.union namespace TestUnion { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -1986,9 +1991,9 @@ namespace TestUnion { // _.unionBy namespace TestUnionBy { - let array: TResult[]; - let list: _.List; - let iteratee: (value: TResult) => any; + let array: TResult[] = []; + let list: _.List = []; + let iteratee: (value: TResult) => any = (value: TResult) => 1; { let result: TResult[]; @@ -2151,11 +2156,8 @@ namespace TestUnionBy { namespace TestUniq { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[]; - let list: _.List; - - let stringIterator: (value: string, index: number, collection: string) => string; - let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + let array: SampleObject[] = []; + let list: _.List = []; { let result: string[]; @@ -2199,11 +2201,11 @@ namespace TestUniq { namespace TestUniqBy { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[]; - let list: _.List; + let array: SampleObject[] = []; + let list: _.List = []; - let stringIterator: (value: string, index: number, collection: string) => string; - let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + let stringIterator = (value: string, index: number, collection: string) => ""; + let listIterator = (value: SampleObject, index: number, collection: _.List) => 0; { let result: string[]; @@ -2273,11 +2275,8 @@ namespace TestUniqBy { namespace TestSortedUniq { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[]; - let list: _.List; - - let stringIterator: (value: string, index: number, collection: string) => string; - let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + let array: SampleObject[] = []; + let list: _.List = []; { let result: string[]; @@ -2317,11 +2316,11 @@ namespace TestSortedUniq { namespace TestSortedUniqBy { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[]; - let list: _.List; + let array: SampleObject[] = []; + let list: _.List = []; - let stringIterator: (value: string, index: number, collection: string) => string; - let listIterator: (value: SampleObject, index: number, collection: _.List) => number; + let stringIterator = (value: string, index: number, collection: string) => ""; + let listIterator = (value: SampleObject, index: number, collection: _.List) => 0; { let result: string[]; @@ -2422,9 +2421,9 @@ namespace TestUnzip { // _.unzipWith { - let testUnzipWithArray: (number[]|_.List)[]; - let testUnzipWithList: _.List>; - let testUnzipWithIterator: {(prev: TResult, curr: number, index?: number, list?: number[]): TResult}; + let testUnzipWithArray: (number[]|_.List)[] = []; + let testUnzipWithList: _.List> = []; + let testUnzipWithIterator: {(prev: TResult, curr: number, index?: number, list?: number[]): TResult} = (prev: TResult, curr: number, index?: number, list?: number[]) => ({ a: 1, b: "", c: true }); let result: TResult[]; result = _.unzipWith(testUnzipWithArray); result = _.unzipWith(testUnzipWithArray, testUnzipWithIterator); @@ -2436,8 +2435,8 @@ namespace TestUnzip { // _.without namespace TestWithout { - let array: number[]; - let list: _.List; + let array: number[] = []; + let list: _.List = []; { let result: number[]; @@ -2483,8 +2482,8 @@ namespace TestWithout { // _.xor namespace TestXor { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[]; @@ -2527,8 +2526,8 @@ namespace TestXor { // _.zip namespace TestZip { - let array: TResult[]; - let list: _.List; + let array: TResult[] = []; + let list: _.List = []; { let result: TResult[][]; @@ -2565,13 +2564,13 @@ namespace TestZip { // _.zipObject namespace TestZipObject { - let arrayOfKeys: string[]; - let arrayOfValues: number[]; - let arrayOfKeyValuePairs: (string|number)[][] + let arrayOfKeys: string[] = []; + let arrayOfValues: number[] = []; + let arrayOfKeyValuePairs: (string|number)[][] = []; - let listOfKeys: _.List; - let listOfValues: _.List; - let listOfKeyValuePairs: _.List<_.List>; + let listOfKeys: _.List = []; + let listOfValues: _.List = []; + let listOfKeyValuePairs: _.List<_.List> = []; { let result: _.Dictionary; @@ -2717,7 +2716,7 @@ namespace TestZipObject { interface TestZipWithFn { (a1: number, a2: number): number; } -let testZipWithFn: TestZipWithFn; +let testZipWithFn: TestZipWithFn = (a1, a2) => 1; result = _.zipWith([1, 2]); result = _.zipWith([1, 2], testZipWithFn); result = _.zipWith([1, 2], [1, 2], testZipWithFn); @@ -2775,28 +2774,28 @@ namespace TestChain { // _.tap namespace TestTap { { - let interceptor: (value: string) => void; + let interceptor = (value: string) => {}; let result: string; _.tap('', interceptor); } { - let interceptor: (value: string[]) => void; + let interceptor = (value: string[]) => {}; let result: _.LoDashImplicitArrayWrapper; _.tap([''], interceptor); } { - let interceptor: (value: {a: string}) => void; + let interceptor = (value: {a: string}) => {}; let result: _.LoDashImplicitObjectWrapper<{a: string}>; _.tap({a: ''}, interceptor); } { - let interceptor: (value: string) => void; + let interceptor = (value: string) => {}; let result: _.LoDashImplicitWrapper; _.chain('').tap(interceptor); @@ -2805,7 +2804,7 @@ namespace TestTap { } { - let interceptor: (value: string[]) => void; + let interceptor = (value: string[]) => {}; let result: _.LoDashImplicitArrayWrapper; _.chain(['']).tap(interceptor); @@ -2814,7 +2813,7 @@ namespace TestTap { } { - let interceptor: (value: {a: string}) => void; + let interceptor = (value: {a: string}) => {}; let result: _.LoDashImplicitObjectWrapper<{a: string}>; _.chain({a: ''}).tap(interceptor); @@ -2823,7 +2822,7 @@ namespace TestTap { } { - let interceptor: (value: string) => void; + let interceptor = (value: string) => {}; let result: _.LoDashExplicitWrapper; _.chain('').tap(interceptor); @@ -2832,7 +2831,7 @@ namespace TestTap { } { - let interceptor: (value: string[]) => void; + let interceptor = (value: string[]) => {}; let result: _.LoDashExplicitArrayWrapper; _.chain(['']).tap(interceptor); @@ -2841,7 +2840,7 @@ namespace TestTap { } { - let interceptor: (value: {a: string}) => void; + let interceptor = (value: {a: string}) => {}; let result: _.LoDashExplicitObjectWrapper<{a: string}>; _.chain({a: ''}).tap(interceptor); @@ -2857,77 +2856,77 @@ namespace TestThru { } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: number; result = _.thru(1, interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashImplicitWrapper; result = _(1).thru(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashImplicitWrapper; result = _('').thru(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashImplicitWrapper; result = _(true).thru(interceptor); } { - let interceptor: Interceptor<{a: string}>; + let interceptor: Interceptor<{a: string}> = (x) => x; let result: _.LoDashImplicitObjectWrapper<{a: string}>; result = _({a: ''}).thru<{a: string}>(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashImplicitArrayWrapper; result = _([1, 2, 3]).thru(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashExplicitWrapper; result = _(1).chain().thru(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashExplicitWrapper; result = _('').chain().thru(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashExplicitWrapper; result = _(true).chain().thru(interceptor); } { - let interceptor: Interceptor<{a: string}>; + let interceptor: Interceptor<{a: string}> = (x) => x; let result: _.LoDashExplicitObjectWrapper<{a: string}>; result = _({a: ''}).chain().thru<{a: string}>(interceptor); } { - let interceptor: Interceptor; + let interceptor: Interceptor = (x) => x; let result: _.LoDashExplicitArrayWrapper; result = _([1, 2, 3]).chain().thru(interceptor); @@ -3255,9 +3254,9 @@ namespace TestValueOf { // _.at namespace TestAt { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; { let result: TResult[]; @@ -3286,15 +3285,15 @@ namespace TestAt { // _.countBy namespace TestCountBy { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; - let stringIterator: (value: string, index: number, collection: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; - let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => any; + let stringIterator: (value: string, index: number, collection: string) => any = (value: string, index: number, collection: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; + let numericDictionaryIterator: (value: TResult, key: number, collection: _.NumericDictionary) => any = (value: TResult, key: number, collection: _.NumericDictionary) => 1; { let result: _.Dictionary; @@ -3392,13 +3391,13 @@ namespace TestCountBy { // _.each namespace TestEach { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string; @@ -3475,13 +3474,13 @@ namespace TestEach { // _.eachRight namespace TestEachRight { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string; @@ -3560,14 +3559,14 @@ namespace TestEachRight { namespace TestEvery { type SampleObject = {a: number; b: string; c: boolean;}; - let array: SampleObject[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: SampleObject[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; - let listIterator: (value: SampleObject, index: number, collection: _.List) => boolean; - let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary) => boolean; - let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary) => boolean; + let listIterator = (value: SampleObject, index: number, collection: _.List) => true; + let dictionaryIterator = (value: SampleObject, key: string, collection: _.Dictionary) => true; + let numericDictionaryIterator = (value: SampleObject, key: number, collection: _.NumericDictionary) => true; { let result: boolean; @@ -3652,13 +3651,13 @@ namespace TestEvery { // _.filter namespace TestFilter { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string[]; @@ -3738,14 +3737,14 @@ namespace TestFilter { // _.find namespace TestFind { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: TResult, index: number, collection: _.List) => boolean; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => boolean; + let listIterator = (value: TResult, index: number, collection: _.List) => true; + let dictionaryIterator = (value: TResult, key: string, collection: _.Dictionary) => true; - let result: TResult; + let result: TResult | undefined; result = _.find(array); result = _.find(array, listIterator); @@ -3822,13 +3821,13 @@ namespace TestFlatMap { let numNumericDictionary: _.NumericDictionary = {0: 1, 1: [2, 3]}; let objNumericDictionary: _.NumericDictionary<{a: number}|{a: number}[]> = {0: {a: 1}, 1: [{a: 2}, {a: 3}]}; - let stringIterator: (value: string, index: number, collection: _.List) => string|string[]; + let stringIterator: (value: string, index: number, collection: _.List) => string|string[] = (a, b, c) => ""; - let listIterator: (value: number, index: number, collection: _.List) => number|number[]; + let listIterator: (value: number, index: number, collection: _.List) => number|number[] = (a, b, c) => 1; - let dictionaryIterator: (value: number, key: number, collection: _.Dictionary) => number|number[]; + let dictionaryIterator: (value: number, key: number, collection: _.Dictionary) => number|number[] = (a, b, c) => 1; - let numericDictionaryIterator: (value: number, key: number, collection: _.NumericDictionary) => number|number[]; + let numericDictionaryIterator: (value: number, key: number, collection: _.NumericDictionary) => number|number[] = (a, b, c) => 1; { let result: string[]; @@ -4001,13 +4000,13 @@ namespace TestFlatMap { // _.forEach namespace TestForEach { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string; @@ -4084,13 +4083,13 @@ namespace TestForEach { // _.forEachRight namespace TestForEachRight { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string; @@ -4169,13 +4168,13 @@ namespace TestForEachRight { namespace TestGroupBy { type SampleType = {a: number; b: string; c: boolean;}; - let array: SampleType[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: SampleType[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => number; - let listIterator: (value: SampleType, index: number, collection: _.List) => number; - let dictionaryIterator: (value: SampleType, key: string, collection: _.Dictionary) => number; + let stringIterator = (char: string, index: number, string: string) => 0; + let listIterator = (value: SampleType, index: number, collection: _.List) => 0; + let dictionaryIterator = (value: SampleType, key: string, collection: _.Dictionary) => 0; { let result: _.Dictionary; @@ -4291,11 +4290,11 @@ namespace TestGroupBy { namespace TestIncludes { type SampleType = {a: string; b: number; c: boolean;}; - let array: SampleType[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: SampleType[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let target: SampleType; + let target: SampleType = { a: "", b: 1, c: true }; { let result: boolean; @@ -4337,15 +4336,15 @@ namespace TestIncludes { namespace TestKeyBy { type SampleObject = {a: number; b: string; c: boolean;}; - let array: SampleObject[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: SampleObject[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; - let stringIterator: (value: string, index: number, collection: string) => any; - let listIterator: (value: SampleObject, index: number, collection: _.List) => any; - let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary) => any; - let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary) => any; + let stringIterator: (value: string, index: number, collection: string) => any = (value: string, index: number, collection: string) => 1; + let listIterator: (value: SampleObject, index: number, collection: _.List) => any = (value: SampleObject, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary) => any = (value: SampleObject, key: string, collection: _.Dictionary) => 1; + let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary) => any = (value: SampleObject, key: number, collection: _.NumericDictionary) => 1; { let result: _.Dictionary; @@ -4583,12 +4582,12 @@ namespace TestInvokeMap { // _.map namespace TestMap { - let array: number[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: number[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: number, index: number, collection: _.List) => TResult; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => TResult; + let listIterator: (value: number, index: number, collection: _.List) => TResult = (value: number, index: number, collection: _.List) => ({ a: 1, b: "", c: true }); + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => TResult = (value: number, key: string, collection: _.Dictionary) => ({ a: 1, b: "", c: true }); { _.map(array); // $ExpectType number[] @@ -4698,9 +4697,9 @@ result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a', // d: {b: TResult}[]; // } // -// let array: SampleObject[]; -// let list: _.List; -// let dictionary: _.Dictionary; +// let array: SampleObject[] = []; +// let list: _.List = []; +// let dictionary: _.Dictionary = {}; // // { // let result: any[]; @@ -4776,19 +4775,19 @@ namespace TestReduce { result = _({ 'a': 1, 'b': 2, 'c': 3 }).reduce((r: ABC, num: number, key: string) => { r[key] = num * 3; return r; - }, {}); + }, { a: 1, b: 2, c: 3 }); result = _.reduceRight([[0, 1], [2, 3], [4, 5]], (a: number[], b: number[]) => a.concat(b), []); } // _.reject namespace TestReject { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let stringIterator: (char: string, index: number, string: string) => any; - let listIterator: (value: TResult, index: number, collection: _.List) => any; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any; + let stringIterator: (char: string, index: number, string: string) => any = (char: string, index: number, string: string) => 1; + let listIterator: (value: TResult, index: number, collection: _.List) => any = (value: TResult, index: number, collection: _.List) => 1; + let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => any = (value: TResult, key: string, collection: _.Dictionary) => 1; { let result: string[]; @@ -4859,10 +4858,10 @@ namespace TestReject { // _.sample namespace TestSample { - let array: string[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: string[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; { let result: string; @@ -4897,10 +4896,10 @@ namespace TestSample { // _.sampleSize namespace TestSampleSize { - let array: string[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: string[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; { let result: string[]; @@ -4958,9 +4957,9 @@ namespace TestSampleSize { // _.shuffle namespace TestShuffle { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; { let result: string[]; @@ -5009,9 +5008,9 @@ namespace TestShuffle { namespace TestSize { type SampleType = {a: string; b: number; c: boolean;}; - let array: SampleType[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: SampleType[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; { let result: number; @@ -5041,16 +5040,16 @@ namespace TestSize { namespace TestSome { type SampleObject = {a: number; b: string; c: boolean;}; - let array: SampleObject[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; - let sampleObject: SampleObject; + let array: SampleObject[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; + let sampleObject: SampleObject = { a: 1, b: "", c: true }; - let listIterator: (value: SampleObject, index: number, collection: _.List) => boolean; - let dictionaryIterator: (value: SampleObject, key: string, collection: _.Dictionary) => boolean; - let numericDictionaryIterator: (value: SampleObject, key: number, collection: _.NumericDictionary) => boolean; - let objectIterator: (value: any, key: string, collection: any) => boolean; + let listIterator = (value: SampleObject, index: number, collection: _.List) => true; + let dictionaryIterator = (value: SampleObject, key: string, collection: _.Dictionary) => true; + let numericDictionaryIterator = (value: SampleObject, key: number, collection: _.NumericDictionary) => true; + let objectIterator = (value: any, key: string, collection: any) => true; { let result: boolean; @@ -5068,7 +5067,13 @@ namespace TestSome { result = _.some(list, {a: 42}); result = _.some(dictionary); - result = _.some(dictionary, dictionaryIterator); + result = _.some(numericDictionary, dictionaryIterator); + result = _.some(dictionary, (value, key, collection) => { + value.a--; + key.substr(0); + value = collection[key]; + return true; + }); result = _.some(dictionary, 'a'); result = _.some(dictionary, ['a', 42]); result = _.some(dictionary, {a: 42}); @@ -5153,12 +5158,12 @@ namespace TestSome { // _.sortBy namespace TestSortBy { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: TResult, index: number, collection: _.List) => number; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => number; + let listIterator = (value: TResult, index: number, collection: _.List) => 0; + let dictionaryIterator = (value: TResult, key: string, collection: _.Dictionary) => 0; { let result: TResult[]; @@ -5228,14 +5233,14 @@ result = _(foodsOrganic).sortBy('organic', (food) => food.name, namespace TestorderBy { type SampleObject = {a: number; b: string; c: boolean}; - let array: SampleObject[]; - let list: _.List; - let numericDictionary: _.NumericDictionary; - let dictionary: _.Dictionary; - let orders: boolean|string|(boolean|string)[]; + let array: SampleObject[] = []; + let list: _.List = []; + let numericDictionary: _.NumericDictionary = {}; + let dictionary: _.Dictionary = {}; + let orders: boolean|string|(boolean|string)[] = true as any; { - let iteratees: (value: string) => any|((value: string) => any)[]; + let iteratees: (value: string) => any|((value: string) => any)[] = (value) => 1; let result: string[]; result = _.orderBy('acbd', iteratees); @@ -5243,7 +5248,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => 1; let result: SampleObject[]; result = _.orderBy<{a: number}, SampleObject>(array, iteratees); @@ -5268,7 +5273,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; let result: _.LoDashImplicitArrayWrapper; result = _(array).orderBy<{a: number}>(iteratees); @@ -5291,7 +5296,7 @@ namespace TestorderBy { } { - let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[]; + let iteratees: (value: SampleObject) => any|string|{a: number}|((value: SampleObject) => any|string|{a: number})[] = (value) => ""; let result: _.LoDashExplicitArrayWrapper; result = _(array).chain().orderBy<{a: number}>(iteratees); @@ -5346,7 +5351,7 @@ namespace TestAfter { (a: string, b: number): boolean; } - let func: Func; + let func: Func = (a, b) => true; { let result: Func; @@ -5371,7 +5376,7 @@ namespace TestAfter { namespace TestAry { type SampleFunc = (a: number, b: string) => boolean; - let func: SampleFunc; + let func: SampleFunc = (a, b) => true; { let result: SampleFunc; @@ -5403,7 +5408,7 @@ namespace TestBefore { (a: string, b: number): boolean; } - let func: Func; + let func: Func = (a, b) => true; { let result: Func; @@ -5428,7 +5433,7 @@ namespace TestBefore { namespace TestBind { type SampleFunc = (a: number, b: string) => boolean; - let func: SampleFunc + let func: SampleFunc = (a, b) => true; { type SampleResult = (a: number, b: string) => boolean; @@ -5514,7 +5519,7 @@ namespace TestBindAll { c: Function; } - let object: SampleObject; + let object: SampleObject = { a: () => {}, b: () => {}, c: () => {} }; { let result: SampleObject; @@ -5546,9 +5551,9 @@ namespace TestBindAll { // _.bindKey namespace TestBindKey { - let object: { - foo(a: number, b: string): boolean; - } + let object = { + foo: (a: number, b: string) => true, + }; { type SampleResult = (a: number, b: string) => boolean; @@ -5699,8 +5704,8 @@ namespace TestDebounce { cancel(): void; } - let func: SampleFunc; - let options: Options; + let func: SampleFunc = (a, b) => true; + let options: Options = {}; { let result: ResultFunc; @@ -5731,7 +5736,7 @@ namespace TestDebounce { namespace TestDefer { type SampleFunc = (a: number, b: string) => boolean; - let func: SampleFunc; + let func: SampleFunc = (a, b) => true; { let result: number; @@ -5765,7 +5770,7 @@ namespace TestDefer { namespace TestDelay { type SampleFunc = (a: number, b: string) => boolean; - let func: SampleFunc; + let func: SampleFunc = (a, b) => true; { let result: number; @@ -5798,7 +5803,7 @@ namespace TestFlip { (a: number, b: string): boolean; } - let func: Func; + let func: Func = (a, b) => true; { let result: Func; @@ -5821,10 +5826,10 @@ namespace TestFlip { // _.flow namespace TestFlow { - let Fn1: (n: number) => number; - let Fn2: (m: number, n: number) => number; - let Fn3: (a: number) => string; - let Fn4: (a: string) => number; + let Fn1 = (n: number) => 0; + let Fn2 = (m: number, n: number) => 0; + let Fn3 = (a: number) => ""; + let Fn4 = (a: string) => 0; { // type infer test @@ -5866,8 +5871,8 @@ namespace TestFlow { // _.flowRight namespace TestFlowRight { - let Fn1: (n: number) => number; - let Fn2: (m: number, n: number) => number; + let Fn1 = (n: number) => 0; + let Fn2 = (m: number, n: number) => 0; { let result: (m: number, n: number) => number; @@ -5897,7 +5902,8 @@ namespace TestFlowRight { // _.memoize namespace TestMemoize { { - let memoizedFunction: _.MemoizedFunction; + let fn: any = () => {}; + let memoizedFunction: _.MemoizedFunction = fn; let cache: _.MapCache = memoizedFunction.cache; } @@ -5905,8 +5911,8 @@ namespace TestMemoize { (a1: string, a2: number): boolean; } - let memoizeFn: (a1: string, a2: number) => boolean; - let memoizeResolverFn: (a1: string, a2: number) => string; + let memoizeFn = (a1: string, a2: number) => true; + let memoizeResolverFn = (a1: string, a2: number) => ""; { let result: MemoizedResultFn; @@ -5938,12 +5944,14 @@ namespace TestMemoize { has(key: K): boolean; set(key: K, value: V): this; } - interface MemoizeCacheConstructor { - new (): MemoizeCache; + class MemoizeCacheClass implements MemoizeCache { + delete: (key: any) => true; + get: (key: any) => 1; + has: (key: any) => true; + set: (key: any, value: any) => this; } - let MemoizeCache: MemoizeCacheConstructor - _.memoize.Cache = MemoizeCache; + _.memoize.Cache = MemoizeCacheClass; } // _.overArgs @@ -5951,11 +5959,11 @@ namespace TestOverArgs { type Func1 = (a: boolean) => boolean; type Func2 = (a: boolean, b: boolean) => boolean; - let func1: Func1; - let func2: Func2; + let func1: Func1 = (a) => true; + let func2: Func2 = (a, b) => true; - let transform1: (a: string) => boolean; - let transform2: (b: number) => boolean; + let transform1 = (a: string) => true; + let transform2 = (b: number) => true; { let result: (a: string) => boolean; @@ -6040,7 +6048,7 @@ namespace TestOnce { (a: number, b: string): boolean; } - let func: Func; + let func: Func = (a, b) => true; { let result: Func; @@ -6089,7 +6097,7 @@ namespace TestRest { type Func = (a: string, b: number[]) => boolean; type ResultFunc = (a: string, ...b: number[]) => boolean; - let func: Func; + let func: Func = (a, b) => true; { let result: ResultFunc; @@ -6121,7 +6129,7 @@ namespace TestSpread { type SampleFunc = (args: (number|string)[]) => boolean; type SampleResult = (a: number, b: string) => boolean; - let func: SampleFunc; + let func: SampleFunc = (a) => true; { let result: SampleResult; @@ -6159,8 +6167,8 @@ namespace TestThrottle { cancel(): void; } - let func: SampleFunc; - let options: Options; + let func: SampleFunc = (a, b) => true; + let options: Options = {}; { let result: ResultFunc; @@ -6193,7 +6201,7 @@ namespace TestUnary { (a: number, b: string): boolean; } - let func: Func; + let func: Func = (a, b) => true; { let result: Func; @@ -6222,8 +6230,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: SampleValue, arg2: number, arg3: string) => boolean; - let value: SampleValue; - let wrapper: SampleWrapper; + let value: SampleValue = { a: 1, b: "", c: true }; + let wrapper: SampleWrapper = (a, b, c) => true; let result: SampleResult; result = _.wrap(value, wrapper); @@ -6234,8 +6242,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: number, arg2: number, arg3: string) => boolean; - let value: number; - let wrapper: SampleWrapper; + let value: number = 0; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashImplicitObjectWrapper; result = _(value).wrap(wrapper); @@ -6245,8 +6253,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: number[], arg2: number, arg3: string) => boolean; - let value: number[]; - let wrapper: SampleWrapper; + let value: number[] = []; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashImplicitObjectWrapper; result = _(value).wrap(wrapper); @@ -6256,8 +6264,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: SampleValue, arg2: number, arg3: string) => boolean; - let value: SampleValue; - let wrapper: SampleWrapper; + let value: SampleValue = { a: 1, b: "", c: true }; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashImplicitObjectWrapper; result = _(value).wrap(wrapper); @@ -6267,8 +6275,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: number, arg2: number, arg3: string) => boolean; - let value: number; - let wrapper: SampleWrapper; + let value: number = 0; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashExplicitObjectWrapper; result = _(value).chain().wrap(wrapper); @@ -6278,8 +6286,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: number[], arg2: number, arg3: string) => boolean; - let value: number[]; - let wrapper: SampleWrapper; + let value: number[] = []; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashExplicitObjectWrapper; result = _(value).chain().wrap(wrapper); @@ -6289,8 +6297,8 @@ namespace TestWrap { { type SampleWrapper = (arg1: SampleValue, arg2: number, arg3: string) => boolean; - let value: SampleValue; - let wrapper: SampleWrapper; + let value: SampleValue = { a: 1, b: "", c: true }; + let wrapper: SampleWrapper = (a, b, c) => true; let result: _.LoDashExplicitObjectWrapper; result = _(value).chain().wrap(wrapper); @@ -6428,7 +6436,7 @@ namespace TestCloneDeepWith { } { - let customizer: CloneDeepWithCustomizer; + let customizer: CloneDeepWithCustomizer = (x) => ""; let reslut: string; result = _.cloneDeepWith(42, customizer); @@ -6437,14 +6445,14 @@ namespace TestCloneDeepWith { } { - let customizer: CloneDeepWithCustomizer; + let customizer: CloneDeepWithCustomizer = (x) => ""; let result: _.LoDashExplicitWrapper; result = _(42).chain().cloneDeepWith(customizer); } { - let customizer: CloneDeepWithCustomizer; + let customizer: CloneDeepWithCustomizer = (x) => []; let reslut: string[]; result = _.cloneDeepWith([42], customizer); @@ -6453,14 +6461,14 @@ namespace TestCloneDeepWith { } { - let customizer: CloneDeepWithCustomizer; + let customizer: CloneDeepWithCustomizer = (x) => []; let result: _.LoDashExplicitArrayWrapper; result = _([42]).chain().cloneDeepWith(customizer); } { - let customizer: CloneDeepWithCustomizer<{a: {b: number;};}, {a: {b: string;};}>; + let customizer: CloneDeepWithCustomizer<{a: {b: number;};}, {a: {b: string;};}> = (x) => ({ a: { b: "" } }); let reslut: {a: {b: string;};}; result = _.cloneDeepWith<{a: {b: string;};}>({a: {b: 42}}, customizer); @@ -6469,7 +6477,7 @@ namespace TestCloneDeepWith { } { - let customizer: CloneDeepWithCustomizer<{a: {b: number;};}, {a: {b: string;};}>; + let customizer: CloneDeepWithCustomizer<{a: {b: number;};}, {a: {b: string;};}> = (x) => ({ a: { b: "" } }); let result: _.LoDashExplicitObjectWrapper<{a: {b: string;};}>; result = _({a: {b: 42}}).chain().cloneDeepWith<{a: {b: string;};}>(customizer); @@ -6483,7 +6491,7 @@ namespace TestCloneWith { } { - let customizer: CloneWithCustomizer; + let customizer: CloneWithCustomizer = (x) => ""; let reslut: string; result = _.cloneWith(42, customizer); @@ -6492,14 +6500,14 @@ namespace TestCloneWith { } { - let customizer: CloneWithCustomizer; + let customizer: CloneWithCustomizer = (x) => ""; let result: _.LoDashExplicitWrapper; result = _(42).chain().cloneWith(customizer); } { - let customizer: CloneWithCustomizer; + let customizer: CloneWithCustomizer = (x) => []; let reslut: string[]; result = _.cloneWith([42], customizer); @@ -6508,14 +6516,14 @@ namespace TestCloneWith { } { - let customizer: CloneWithCustomizer; + let customizer: CloneWithCustomizer = (x) => []; let result: _.LoDashExplicitArrayWrapper; result = _([42]).chain().cloneWith(customizer); } { - let customizer: CloneWithCustomizer<{a: {b: number;};}, {a: {b: string;};}>; + let customizer: CloneWithCustomizer<{a: {b: number;};}, {a: {b: string;};}> = (x) => ({ a: { b: "" } }); let reslut: {a: {b: string;};}; result = _.cloneWith<{a: {b: string;};}>({a: {b: 42}}, customizer); @@ -6524,7 +6532,7 @@ namespace TestCloneWith { } { - let customizer: CloneWithCustomizer<{a: {b: number;};}, {a: {b: string;};}>; + let customizer: CloneWithCustomizer<{a: {b: number;};}, {a: {b: string;};}> = (x) => ({ a: { b: "" } }); let result: _.LoDashExplicitObjectWrapper<{a: {b: string;};}>; result = _({a: {b: 42}}).chain().cloneWith<{a: {b: string;};}>(customizer); @@ -6605,7 +6613,7 @@ namespace TestGte { // _.isArguments namespace TestisArguments { { - let value: number|IArguments; + let value: number|IArguments = 0; if (_.isArguments(value)) { let result: IArguments = value; @@ -6636,7 +6644,7 @@ namespace TestisArguments { // _.isArray namespace TestIsArray { { - let value: number|string[]|boolean[]; + let value: number|string[]|boolean[] = []; if (_.isArray(value)) { let result: string[] = value; @@ -6672,7 +6680,7 @@ namespace TestIsArray { // _.isArrayBuffer namespace TestIsArrayBuffer { { - let value: ArrayBuffer|number; + let value: ArrayBuffer|number = 0; if (_.isArrayBuffer(value)) { let result: ArrayBuffer = value; @@ -6703,7 +6711,7 @@ namespace TestIsArrayBuffer { // _.isArrayLike namespace TestIsArrayLike { { - let value: number|string[]|boolean[]; + let value: number|string[]|boolean[] = []; if (_.isArrayLike(value)) { let result: string[] = value; @@ -6739,7 +6747,7 @@ namespace TestIsArrayLike { // _.isArrayLikeObject namespace TestIsArrayLikeObject { { - let value: number|string[]|boolean[]; + let value: number|string[]|boolean[] = []; if (_.isArrayLikeObject(value)) { let result: string[] = value; @@ -6775,7 +6783,7 @@ namespace TestIsArrayLikeObject { // _.isBoolean namespace TestIsBoolean { { - let value: number|boolean; + let value: number|boolean = 0; if (_.isBoolean(value)) { let result: boolean = value; @@ -6826,7 +6834,7 @@ namespace TestIsBuffer { // _.isDate namespace TestIsBoolean { { - let value: number|Date; + let value: number|Date = 0; if (_.isDate(value)) { let result: Date = value; @@ -6918,7 +6926,7 @@ namespace TestIsEqual { // _.isEqualWith namespace TestIsEqualWith { - let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean; + let customizer = (value: any, other: any, indexOrKey?: number|string) => true; { let result: boolean; @@ -6937,8 +6945,9 @@ namespace TestIsEqualWith { // _.isError namespace TestIsError { + let x: any = 1; { - let value: number|Error; + let value: number|Error = x; if (_.isError(value)) { let result: Error = value; @@ -6953,7 +6962,7 @@ namespace TestIsError { custom: string } - let value: number|CustomError; + let value: number|CustomError = x; if (_.isError(value)) { let result: CustomError = value; @@ -7004,7 +7013,7 @@ namespace TestIsFinite { // _.isFunction namespace TestIsFunction { { - let value: number|Function; + let value: number|Function = () => {}; if (_.isFunction(value)) { let result: Function = value; @@ -7077,7 +7086,7 @@ namespace TestIsLength { // _.isMap namespace TestIsMap { { - let value: number|Map; + let value: number|Map = 0; if (_.isMap(value)) { let result: Map = value; @@ -7117,7 +7126,7 @@ namespace TestIsMatch { // _.isMatchWith namespace TestIsMatchWith { - let testIsMatchCustiomizerFn: (value: any, other: any, indexOrKey: number|string) => boolean; + let testIsMatchCustiomizerFn = (value: any, other: any, indexOrKey: number|string) => true; let result: boolean; @@ -7149,7 +7158,7 @@ namespace TestIsNaN { // _.isNative namespace TestIsNative { { - let value: number|Function; + let value: number|Function = () => {}; if (_.isNative(value)) { let result: Function = value; @@ -7223,7 +7232,7 @@ namespace TestIsNull { // _.isNumber namespace TestIsNumber { { - let value: string|number; + let value: string|number = 0; if (_.isNumber(value)) { let result: number = value; @@ -7315,7 +7324,7 @@ namespace TestIsPlainObject { // _.isRegExp namespace TestIsRegExp { { - let value: number|RegExp; + let value: number|RegExp = /./; if (_.isRegExp(value)) { let result: RegExp = value; @@ -7367,7 +7376,7 @@ namespace TestIsSafeInteger { // _.isSet namespace TestIsSet { { - let value: number|Set; + let value: number|Set = 0; if (_.isSet(value)) { let result: Set = value; @@ -7398,7 +7407,7 @@ namespace TestIsSet { // _.isString namespace TestIsString { { - let value: number|string; + let value: number|string = ''; if (_.isString(value)) { let result: string = value; @@ -7489,7 +7498,7 @@ namespace TestIsWeakMap { { interface Obj { a: string }; - let value: number|WeakMap; + let value: number|WeakMap = 0; if (_.isWeakMap(value)) { let result: WeakMap = value; @@ -7520,7 +7529,7 @@ namespace TestIsWeakMap { // _.isWeakSet namespace TestIsWeakSet { { - let value: number|WeakSet; + let value: number|WeakSet = 0; if (_.isWeakSet(value)) { let result: WeakSet = value; @@ -7590,10 +7599,10 @@ namespace TestLte { // _.toArray namespace TestToArray { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; - let numericDictionary: _.NumericDictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; + let numericDictionary: _.NumericDictionary = {}; { let result: string[]; @@ -7824,8 +7833,8 @@ namespace TestFloor { // _.max namespace TestMax { - let array: number[]; - let list: _.List; + let array: number[] = []; + let list: _.List = []; let result: number; @@ -7838,12 +7847,12 @@ namespace TestMax { // _.maxBy namespace TestMaxBy { - let array: number[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: number[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: number, index: number, collection: _.List) => number; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => number; + let listIterator = (value: number, index: number, collection: _.List) => 0; + let dictionaryIterator = (value: number, key: string, collection: _.Dictionary) => 0; let result: number; @@ -7880,7 +7889,7 @@ namespace TestMaxBy { // _.mean namespace TestMean { - let array: number[]; + let array: number[] = []; let result: number; @@ -7891,8 +7900,8 @@ namespace TestMean { // _.min namespace TestMin { - let array: number[]; - let list: _.List; + let array: number[] = []; + let list: _.List = []; let result: number; @@ -7905,12 +7914,12 @@ namespace TestMin { // _.minBy namespace TestMinBy { - let array: number[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: number[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: number, index: number, collection: _.List) => number; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => number; + let listIterator = (value: number, index: number, collection: _.List) => 0; + let dictionaryIterator = (value: number, key: string, collection: _.Dictionary) => 0; let result: number; @@ -7967,12 +7976,12 @@ namespace TestRound { // _.sum namespace TestSum { - let array: number[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: number[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: number, index: number, collection: _.List) => number; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => number; + let listIterator = (value: number, index: number, collection: _.List) => 0; + let dictionaryIterator = (value: number, key: string, collection: _.Dictionary) => 0; { let result: number; @@ -8003,13 +8012,13 @@ namespace TestSum { // _.sumBy namespace TestSumBy { - let array: number[]; - let objectArray: { 'age': number }[]; + let array: number[] = []; + let objectArray: { 'age': number }[] = []; - let list: _.List; - let objectList: _.List<{ 'age': number }>; + let list: _.List = []; + let objectList: _.List<{ 'age': number }> = []; - let listIterator: (value: number, index: number, collection: _.List) => number; + let listIterator = (value: number, index: number, collection: _.List) => 0; { let result: number; @@ -8143,14 +8152,12 @@ namespace TestAssign { interface S4 { d: number }; interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; - - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; { let result: Obj; @@ -8270,14 +8277,14 @@ namespace TestAssignWith { interface S4 { d: number }; interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => 1; { let result: Obj; @@ -8382,14 +8389,14 @@ namespace TestAssignIn { interface S4 { d: number }; interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => 1; { let result: Obj; @@ -8509,14 +8516,14 @@ namespace TestAssignInWith { interface S4 { d: number }; interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => 1; { let result: Obj; @@ -8617,8 +8624,8 @@ namespace TestCreate { type SampleProto = {a: number}; type SampleProps = {b: string}; - let prototype: SampleProto; - let properties: SampleProps; + let prototype: SampleProto = { a: 1 }; + let properties: SampleProps = { b: "" }; { let result: {a: number; b: string}; @@ -8651,12 +8658,12 @@ namespace TestDefaults { interface S4 { d: number }; interface S5 { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; { let result: Obj; @@ -8788,14 +8795,14 @@ namespace TestExtend { type S4 = { d: number }; type S5 = { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => 1; { let result: Obj; @@ -8915,14 +8922,14 @@ namespace TestExtendWith { type S4 = { d: number }; type S5 = { e: number }; - let obj: Obj; - let s1: S1; - let s2: S2; - let s3: S3; - let s4: S4; - let s5: S5; + let obj: Obj = { a: "" }; + let s1: S1 = { a: 1 }; + let s2: S2 = { b: 1 }; + let s3: S3 = { c: 1 }; + let s4: S4 = { d: 1 }; + let s5: S5 = { e: 1 }; - let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any; + let customizer: (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => any = (objectValue: any, sourceValue: any, key?: string, object?: {}, source?: {}) => 1; { let result: Obj; @@ -9036,7 +9043,7 @@ namespace TestExtendWith { // _.findKey namespace TestFindKey { { - let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let predicateFn = (value: any, key: string, object: {}) => true; let result: string; result = _.findKey<{a: string;}>({a: ''}); @@ -9057,7 +9064,7 @@ namespace TestFindKey { } { - let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let predicateFn = (value: string, key: string, collection: _.Dictionary) => true; let result: string; result = _.findKey({a: ''}, predicateFn); @@ -9066,7 +9073,7 @@ namespace TestFindKey { } { - let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let predicateFn = (value: any, key: string, object: {}) => true; let result: _.LoDashExplicitWrapper; result = _<{a: string;}>({a: ''}).chain().findKey(); @@ -9079,7 +9086,7 @@ namespace TestFindKey { } { - let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let predicateFn = (value: string, key: string, collection: _.Dictionary) => true; let result: _.LoDashExplicitWrapper; result = _<{a: string;}>({a: ''}).chain().findKey(predicateFn); @@ -9089,7 +9096,7 @@ namespace TestFindKey { // _.findLastKey namespace TestFindLastKey { { - let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let predicateFn = (value: any, key: string, object: {}) => true; let result: string; result = _.findLastKey<{a: string;}>({a: ''}); @@ -9110,7 +9117,7 @@ namespace TestFindLastKey { } { - let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let predicateFn = (value: string, key: string, collection: _.Dictionary) => true; let result: string; result = _.findLastKey({a: ''}, predicateFn); @@ -9119,7 +9126,7 @@ namespace TestFindLastKey { } { - let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let predicateFn = (value: any, key: string, object: {}) => true; let result: _.LoDashExplicitWrapper; result = _<{a: string;}>({a: ''}).chain().findLastKey(); @@ -9132,7 +9139,7 @@ namespace TestFindLastKey { } { - let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let predicateFn = (value: string, key: string, collection: _.Dictionary) => true; let result: _.LoDashExplicitWrapper; result = _<{a: string;}>({a: ''}).chain().findLastKey(predicateFn); @@ -9143,11 +9150,11 @@ namespace TestFindLastKey { namespace TestForIn { type SampleObject = {a: number; b: string; c: boolean;}; - let dictionary: _.Dictionary; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any; + let dictionary: _.Dictionary = {}; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any = (value: number, key: string, collection: _.Dictionary) => 1; - let object: SampleObject; - let objectIterator: (element: any, key?: string, collection?: any) => any; + let object: SampleObject = { a: 1, b: "", c: true }; + let objectIterator: (element: any, key?: string, collection?: any) => any = (element: any, key?: string, collection?: any) => 1; { let result: _.Dictionary; @@ -9182,11 +9189,11 @@ namespace TestForIn { namespace TestForInRight { type SampleObject = {a: number; b: string; c: boolean;}; - let dictionary: _.Dictionary; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any; + let dictionary: _.Dictionary = {}; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any = (value: number, key: string, collection: _.Dictionary) => 1; - let object: SampleObject; - let objectIterator: (element: any, key?: string, collection?: any) => any; + let object: SampleObject = { a: 1, b: "", c: true }; + let objectIterator: (element: any, key?: string, collection?: any) => any = (element: any, key?: string, collection?: any) => 1; { let result: _.Dictionary; @@ -9221,11 +9228,11 @@ namespace TestForInRight { namespace TestForOwn { type SampleObject = {a: number; b: string; c: boolean;}; - let dictionary: _.Dictionary; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any; + let dictionary: _.Dictionary = {}; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any = (value: number, key: string, collection: _.Dictionary) => 1; - let object: SampleObject; - let objectIterator: (element: any, key?: string, collection?: any) => any; + let object: SampleObject = { a: 1, b: "", c: true }; + let objectIterator: (element: any, key?: string, collection?: any) => any = (element: any, key?: string, collection?: any) => 1; { let result: _.Dictionary; @@ -9260,11 +9267,11 @@ namespace TestForOwn { namespace TestForOwnRight { type SampleObject = {a: number; b: string; c: boolean;}; - let dictionary: _.Dictionary; - let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any; + let dictionary: _.Dictionary = {}; + let dictionaryIterator: (value: number, key: string, collection: _.Dictionary) => any = (value: number, key: string, collection: _.Dictionary) => 1; - let object: SampleObject; - let objectIterator: (element: any, key?: string, collection?: any) => any; + let object: SampleObject = { a: 1, b: "", c: true }; + let objectIterator: (element: any, key?: string, collection?: any) => any = (element: any, key?: string, collection?: any) => 1; { let result: _.Dictionary; @@ -9299,7 +9306,7 @@ namespace TestForOwnRight { namespace TestFunctions { type SampleObject = {a: number; b: string; c: boolean;}; - let object: SampleObject; + let object: SampleObject = { a: 1, b: "", c: true }; { let result: string[]; @@ -9324,7 +9331,7 @@ namespace TestFunctions { namespace TestFunctionsIn { type SampleObject = {a: number; b: string; c: boolean;}; - let object: SampleObject; + let object: SampleObject = { a: 1, b: "", c: true }; { let result: string[]; @@ -9436,7 +9443,7 @@ namespace TestGet { namespace TestHas { type SampleObject = {a: number; b: string; c: boolean;}; - let object: SampleObject; + let object: SampleObject = { a: 1, b: "", c: true }; { let result: boolean; @@ -9466,7 +9473,7 @@ namespace TestHas { namespace TestHasIn { type SampleObject = {a: number; b: string; c: boolean;}; - let object: SampleObject; + let object: SampleObject = { a: 1, b: "", c: true }; { let result: boolean; @@ -9521,16 +9528,16 @@ namespace TestInvert { // _.invertBy namespace TestInvertBy { - let array: ({a: number;})[]; - let list: _.List<{a: number;}>; - let dictionary: _.Dictionary<{a: number;}>; - let numericDictionary: _.NumericDictionary<{a: number;}>; + let array: ({a: number;})[] = []; + let list: _.List<{a: number;}> = []; + let dictionary: _.Dictionary<{a: number;}> = {}; + let numericDictionary: _.NumericDictionary<{a: number;}> = {}; - let stringIterator: (value: string) => any; - let arrayIterator: (value: {a: number;}) => any; - let listIterator: (value: {a: number;}) => any; - let dictionaryIterator: (value: {a: number;}) => any; - let numericDictionaryIterator: (value: {a: number;}) => any; + let stringIterator: (value: string) => any = (value: string) => 1; + let arrayIterator: (value: {a: number;}) => any = (value: {a: number;}) => 1; + let listIterator: (value: {a: number;}) => any = (value: {a: number;}) => 1; + let dictionaryIterator: (value: {a: number;}) => any = (value: {a: number;}) => 1; + let numericDictionaryIterator: (value: {a: number;}) => any = (value: {a: number;}) => 1; { let result: _.Dictionary; @@ -9616,7 +9623,7 @@ namespace TestInvertBy { // _.keys namespace TestKeys { - let object: _.Dictionary; + let object: _.Dictionary = {}; { let result: string[]; @@ -9639,7 +9646,7 @@ namespace TestKeys { // _.keysIn namespace TestKeysIn { - let object: _.Dictionary; + let object: _.Dictionary = {}; { let result: string[]; @@ -9662,12 +9669,12 @@ namespace TestKeysIn { // _.mapKeys namespace TestMapKeys { - let array: TResult[]; - let list: _.List; - let dictionary: _.Dictionary; + let array: TResult[] = []; + let list: _.List = []; + let dictionary: _.Dictionary = {}; - let listIterator: (value: TResult, index: number, collection: _.List) => string; - let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary) => string; + let listIterator = (value: TResult, index: number, collection: _.List) => ""; + let dictionaryIterator = (value: TResult, key: string, collection: _.Dictionary) => ""; { let result: _.Dictionary; @@ -9828,7 +9835,7 @@ namespace TestMergeWith { type ExpectedResult = { a: number, b: string }; let result: ExpectedResult; - let customizer: (value: any, srcValue: any, key?: string, object?: InitialValue, source?: MergingValue) => any; + let customizer: (value: any, srcValue: any, key?: string, object?: InitialValue, source?: MergingValue) => any = (value: any, srcValue: any, key?: string, object?: InitialValue, source?: MergingValue) => 1; // Test for basic merging result = _.mergeWith(initialValue, mergingValue, customizer); @@ -9883,7 +9890,7 @@ namespace TestOmit { // _.omitBy namespace TestOmitBy { - let predicate: (element: any, key: string, collection: any) => boolean; + let predicate = (element: any, key: string, collection: any) => true; { let result: TResult; @@ -9938,7 +9945,7 @@ namespace TestPick { // _.pickBy namespace TestPickBy { - let predicate: (element: any, key: string, collection: any) => boolean; + let predicate = (element: any, key: string, collection: any) => true; { let result: TResult; @@ -10075,8 +10082,8 @@ namespace TestSet { type SampleObject = {a: {}}; type SampleResult = {a: {b: number[]}}; - let object: SampleObject; - let value: number; + let object: SampleObject = { a: {} }; + let value: number = 0; { let result: SampleResult; @@ -10117,9 +10124,9 @@ namespace TestSetWith { type SampleObject = {a: {}}; type SampleResult = {a: {b: number[]}}; - let object: SampleObject; - let value: number; - let customizer: (value: any, key: string, object: SampleObject) => number; + let object: SampleObject = { a: {} }; + let value: number = 0; + let customizer = (value: any, key: string, object: SampleObject) => 0; { let result: SampleResult; @@ -10171,7 +10178,7 @@ namespace TestSetWith { // _.toPairs namespace TestToPairs { - let object: _.Dictionary; + let object: _.Dictionary = {}; { let result: [string, any][]; @@ -10212,7 +10219,7 @@ namespace TestToPairs { // _.toPairsIn namespace TestToPairsIn { - let object: _.Dictionary; + let object: _.Dictionary = {}; { let result: [string, any][]; @@ -10253,12 +10260,12 @@ namespace TestToPairsIn { // _.transform namespace TestTransform { - let array: number[]; - let dictionary: _.Dictionary; + let array: number[] = []; + let dictionary: _.Dictionary = {}; { - let iterator: (acc: TResult[], curr: number, index?: number, arr?: number[]) => void; - let accumulator: TResult[]; + let iterator = (acc: TResult[], curr: number, index?: number, arr?: number[]) => {}; + let accumulator: TResult[] = []; let result: TResult[]; result = _.transform(array); @@ -10271,8 +10278,8 @@ namespace TestTransform { } { - let iterator: (acc: _.Dictionary, curr: number, index?: number, arr?: number[]) => void; - let accumulator: _.Dictionary; + let iterator = (acc: _.Dictionary, curr: number, index?: number, arr?: number[]) => {}; + let accumulator: _.Dictionary = {}; let result: _.Dictionary; result = _.transform(array, iterator); @@ -10283,8 +10290,8 @@ namespace TestTransform { } { - let iterator: (acc: _.Dictionary, curr: number, key?: string, dict?: _.Dictionary) => void; - let accumulator: _.Dictionary; + let iterator = (acc: _.Dictionary, curr: number, key?: string, dict?: _.Dictionary) => {}; + let accumulator: _.Dictionary = {}; let result: _.Dictionary; result = _.transform(dictionary); @@ -10297,8 +10304,8 @@ namespace TestTransform { } { - let iterator: (acc: TResult[], curr: number, key?: string, dict?: _.Dictionary) => void; - let accumulator: TResult[]; + let iterator = (acc: TResult[], curr: number, key?: string, dict?: _.Dictionary) => {}; + let accumulator: TResult[] = []; let result: TResult[]; result = _.transform(dictionary, iterator); @@ -10313,7 +10320,7 @@ namespace TestTransform { namespace TestUnset { type SampleObject = {a: {b: string; c: boolean}}; - let object: SampleObject; + let object: SampleObject = { a: { b: "", c: true } }; { let result: boolean; @@ -10342,8 +10349,8 @@ namespace TestUpdate { type SampleObject = {a: {}}; type SampleResult = {a: {b: number[]}}; - let object: SampleObject; - let updater: (value: any) => number; + let object: SampleObject = { a: {} }; + let updater = (value: any) => 0; { let result: SampleResult; @@ -10415,10 +10422,10 @@ namespace TestValues { } { - let dict: _.Dictionary; - let numDict: _.NumericDictionary; - let list: _.List; - let object: {a: SampleObject}; + let dict: _.Dictionary = {}; + let numDict: _.NumericDictionary = {}; + let list: _.List = []; + let object: {a: SampleObject} = { a: { a: {} } }; let result: SampleObject[]; result = _.values(dict); @@ -10457,10 +10464,10 @@ namespace TestValues { } { - let dict: _.Dictionary; - let numDict: _.NumericDictionary; - let list: _.List; - let object: {a: SampleObject}; + let dict: _.Dictionary = {}; + let numDict: _.NumericDictionary = {}; + let list: _.List = []; + let object: {a: SampleObject} = { a: { a: {} } }; let result: _.LoDashImplicitArrayWrapper; result = _(dict).values(); @@ -10499,10 +10506,10 @@ namespace TestValues { } { - let dict: _.Dictionary; - let numDict: _.NumericDictionary; - let list: _.List; - let object: {a: SampleObject}; + let dict: _.Dictionary = {}; + let numDict: _.NumericDictionary = {}; + let list: _.List = []; + let object: {a: SampleObject} = { a: { a: {} } }; let result: _.LoDashExplicitArrayWrapper; result = _(dict).chain().values(); @@ -10514,7 +10521,7 @@ namespace TestValues { // _.valuesIn namespace TestValuesIn { - let object: _.Dictionary; + let object: _.Dictionary = {}; { let result: TResult[]; @@ -10956,7 +10963,7 @@ namespace TestTemplate { interpolate?: RegExp; sourceURL?: string; variable?: string; - }; + } = {}; { let result: TemplateExecutor; @@ -11171,7 +11178,7 @@ namespace TestWords { // _.attempt namespace TestAttempt { - let func: (...args: any[]) => {a: string}; + let func: (...args: any[]) => {a: string} = (...args) => ({ a: "" }); { let result: {a: string}|Error; @@ -11487,7 +11494,7 @@ namespace TestIteratee { // _.matches namespace TestMatches { - let source: TResult; + let source: TResult = { a: 1, b: "", c: true }; { let result: (value: any) => boolean; @@ -11512,8 +11519,8 @@ namespace TestMatches { // _.matchesProperty namespace TestMatches { - let path: {toString(): string;}|{toString(): string;}[]; - let source: TResult; + let path: {toString(): string;}|{toString(): string;}[] = []; + let source: TResult = { a: 1, b: "", c: true }; { let result: (value: any) => boolean; @@ -11642,7 +11649,7 @@ namespace TestMethodOf { type SampleObject = { a: { b(): TResult }[] }; type ResultFn = (path: _.StringRepresentable|_.StringRepresentable[]) => TResult; - let object: SampleObject; + let object: SampleObject = { a: [] }; { let result: ResultFn; @@ -11679,8 +11686,8 @@ namespace TestMethodOf { // _.mixin namespace TestMixin { - let source: _.Dictionary; - let options: {chain?: boolean}; + let source: _.Dictionary = {}; + let options: {chain?: boolean} = {}; { let result: TResult; @@ -11909,7 +11916,7 @@ namespace TestPropertyOf { } } - let object: SampleObject; + let object: SampleObject = { a: { b: [] } }; { let result: (path: string|string[]) => any; @@ -12095,7 +12102,7 @@ namespace TestRangeRight { // _.times namespace TestTimes { - let iteratee: (num: number) => TResult; + let iteratee: (num: number) => TResult = (num: number) => ({ a: 1, b: "", c: true }); { let result: number[]; diff --git a/types/lodash/tsconfig.json b/types/lodash/tsconfig.json index c0730d6661..88cd24b85a 100644 --- a/types/lodash/tsconfig.json +++ b/types/lodash/tsconfig.json @@ -299,7 +299,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From 5fc2f8c6703ca755e1f338bea0fedfc670b3abc5 Mon Sep 17 00:00:00 2001 From: Periklis Tsirakidis Date: Fri, 5 May 2017 17:59:06 +0200 Subject: [PATCH 27/50] emscripten: update module api to 1.37.10 (#16310) * Add type aliases for imports and exports * Update emscripten Module API to 1.37.10 --- types/emscripten/emscripten-tests.ts | 19 ++++++++++++++++--- types/emscripten/index.d.ts | 23 ++++++++++++++++++++++- types/webassembly-js-api/index.d.ts | 26 ++++++++++++++++---------- 3 files changed, 54 insertions(+), 14 deletions(-) diff --git a/types/emscripten/emscripten-tests.ts b/types/emscripten/emscripten-tests.ts index 0c7f99b710..153ea6b5de 100644 --- a/types/emscripten/emscripten-tests.ts +++ b/types/emscripten/emscripten-tests.ts @@ -1,8 +1,20 @@ - - - /// Module function ModuleTest(): void { + Module.environment = "WEB"; + Module.environment = "NODE"; + Module.noInitialRun = false; + Module.logReadFiles = false; + Module.filePackagePrefixURL = "http://www.example.org/"; + Module.preinitializedWebGLContext = new WebGLRenderingContext(); + + let package: ArrayBuffer = Module.getPreloadedPackage("package-name", 100); + let exports: WebAssembly.Exports = Module.instantiateWasm( + [{name: "func-name", kind: "function"}], + (module: WebAssembly.Module) => {} + ); + let memFile: string = Module.locateFile("http://www.example.org/file.mem"); + Module.onCustomMessage(new MessageEvent("TestType")); + Module.print = function(text) { alert('stdout: ' + text) }; var int_sqrt = Module.cwrap('int_sqrt', 'number', ['number']) @@ -16,6 +28,7 @@ function ModuleTest(): void { Module.HEAPU8.set(myTypedArray, buf); Module.ccall('my_function', 'number', ['number'], [buf]); Module._free(buf); + Module.destroy({}); } /// FS diff --git a/types/emscripten/index.d.ts b/types/emscripten/index.d.ts index 38e659a0f3..14260dd9d4 100644 --- a/types/emscripten/index.d.ts +++ b/types/emscripten/index.d.ts @@ -1,7 +1,11 @@ // Type definitions for Emscripten // Project: http://kripken.github.io/emscripten-site/index.html // Definitions by: Kensuke Matsuzaki +// Periklis Tsirakidis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// declare namespace Emscripten { interface FileSystemType { @@ -9,13 +13,30 @@ declare namespace Emscripten { } declare namespace Module { + type EnvironmentType = "WEB" | "NODE" | "SHELL" | "WORKER"; + function print(str: string): void; function printErr(str: string): void; var arguments: string[]; + var environment: EnvironmentType; var preInit: { (): void }[]; var preRun: { (): void }[]; var postRun: { (): void }[]; + var preinitializedWebGLContext: WebGLRenderingContext; + var noInitialRun: boolean; var noExitRuntime: boolean; + var logReadFiles: boolean; + var filePackagePrefixURL: string; + var wasmBinary: ArrayBuffer; + + function destroy(object: object): void; + function getPreloadedPackage(remotePackageName: string, remotePackageSize: number): ArrayBuffer; + function instantiateWasm( + imports: WebAssembly.Imports, + successCallback: (module: WebAssembly.Module) => void + ): WebAssembly.Exports; + function locateFile(url: string): string; + function onCustomMessage(event: MessageEvent): void; var Runtime: any; @@ -65,7 +86,7 @@ declare namespace Module { function addOnExit(cb: () => any): void; function addOnPostRun(cb: () => any): void; - // Tools + // Tools function intArrayFromString(stringy: string, dontAddNull?: boolean, length?: number): number[]; function intArrayToString(array: number[]): string; function writeStringToMemory(str: string, buffer: number, dontAddNull: boolean): void; diff --git a/types/webassembly-js-api/index.d.ts b/types/webassembly-js-api/index.d.ts index 4e7b0d52bf..0c8c9d19e8 100644 --- a/types/webassembly-js-api/index.d.ts +++ b/types/webassembly-js-api/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for WebAssembly v1 (MVP) // Project: https://github.com/winksaville/test-webassembly-js-ts -// Definitions by: 01alchemist , Wink Saville +// Definitions by: 01alchemist +// Wink Saville +// Periklis Tsirakidis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** @@ -9,21 +11,25 @@ * for more information. */ declare namespace WebAssembly { + type Imports = Array<{ + name: string; + kind: string; + }>; + + type Exports = Array<{ + module: string; + name: string; + kind: string; + }>; + /** * WebAssembly.Module */ class Module { constructor(bufferSource: ArrayBuffer | Uint8Array); static customSections(module: Module, sectionName: string): ArrayBuffer[]; - static exports(module: Module): Array<{ - name: string; - kind: string; - }>; - static imports(module: Module): Array<{ - module: string; - name: string; - kind: string; - }>; + static exports(module: Module): Imports; + static imports(module: Module): Exports; } /** From 1b926c986b31861abf39bd11534b1f0ccbea3405 Mon Sep 17 00:00:00 2001 From: Kacper Polak Date: Fri, 5 May 2017 17:59:58 +0200 Subject: [PATCH 28/50] Add sql property to Error interface (#16336) Based on commit: https://github.com/mysqljs/mysql/commit/7549c734e5691575d20e7c774d47cda482214bda --- types/mysql/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/mysql/index.d.ts b/types/mysql/index.d.ts index 7660feb374..9212d59ef6 100644 --- a/types/mysql/index.d.ts +++ b/types/mysql/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for node-mysql // Project: https://github.com/felixge/node-mysql // Definitions by: William Johnston +// Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -497,6 +498,11 @@ interface IError extends Error { * Boolean, indicating if this error is terminal to the connection object. */ fatal: boolean; + + /** + * SQL of failed query + */ + sql?: string; } declare const enum FieldType { From ef8ff1dff4a8fce861b6aa8ff6e106e5fa0ae95c Mon Sep 17 00:00:00 2001 From: Carl Winkler Date: Sat, 6 May 2017 00:01:16 +0800 Subject: [PATCH 29/50] Add support and tests for Dockerode promise API (#16337) --- types/dockerode/dockerode-tests.ts | 23 ++++++ types/dockerode/index.d.ts | 108 ++++++++++++++++++++++++++++- types/dockerode/tsconfig.json | 1 + 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/types/dockerode/dockerode-tests.ts b/types/dockerode/dockerode-tests.ts index 4b4e406839..8dd9a380de 100644 --- a/types/dockerode/dockerode-tests.ts +++ b/types/dockerode/dockerode-tests.ts @@ -24,6 +24,25 @@ const docker6 = new Docker({ key: 'key' }); +const docker7 = new Docker({ + Promise +}); + +async function foo() { + const containers = await docker7.listContainers(); + for (const container of containers) { + const foo = await docker7.getContainer(container.Id); + const inspect = await foo.inspect(); + } + + const images = await docker5.listImages(); + for (const image of images) { + const foo = await docker5.getImage(image.Id); + const inspect = await foo.inspect(); + await foo.remove(); + } +} + const container = docker.getContainer('container-id'); container.inspect((err, data) => { // NOOP @@ -47,6 +66,10 @@ docker.listContainers((err, containers) => { }); }); +docker.listContainers().then(containers => { + return containers.map(container => docker.getContainer(container.Id)); +}); + docker.buildImage('archive.tar', { t: 'imageName' }, (err, response) => { // NOOP }); diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index 2e834f0b3b..a4a1144872 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -12,69 +12,93 @@ declare namespace Dockerode { interface Container { inspect(options: {}, callback: Callback): void; inspect(callback: Callback): void; - inspect(options?: {}): { id: string }; + inspect(options?: {}): Promise; rename(options: {}, callback: Callback): void; + rename(options: {}): Promise; update(options: {}, callback: Callback): void; + update(options: {}): Promise; top(options: {}, callback: Callback): void; top(callback: Callback): void; + top(options?: {}): Promise; changes(callback: Callback): void; + changes(): Promise; export(callback: Callback): void; + export(): Promise; start(options: {}, callback: Callback): void; start(callback: Callback): void; + start(options?: {}): Promise; pause(options: {}, callback: Callback): void; pause(callback: Callback): void; + pause(options?: {}): Promise; unpause(options: {}, callback: Callback): void; unpause(callback: Callback): void; + unpause(options?: {}): Promise; exec(options: {}, callback: Callback): void; + exec(options: {}): Promise; commit(options: {}, callback: Callback): void; commit(callback: Callback): void; + commit(options?: {}): Promise; stop(options: {}, callback: Callback): void; stop(callback: Callback): void; + stop(options?: {}): Promise; restart(options: {}, callback: Callback): void; restart(callback: Callback): void; + restart(options?: {}): Promise; kill(options: {}, callback: Callback): void; kill(callback: Callback): void; + kill(options?: {}): Promise; resize(options: {}, callback: Callback): void; resize(callback: Callback): void; + resize(options?: {}): Promise; wait(callback: Callback): void; + wait(): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; /** Deprecated since RAPI v1.20 */ copy(options: {}, callback: Callback): void; /** Deprecated since RAPI v1.20 */ copy(callback: Callback): void; + /** Deprecated since RAPI v1.20 */ + copy(options?: {}): Promise; getArchive(options: {}, callback: Callback): void; + getArchive(options: {}): Promise; infoArchive(options: {}, callback: Callback): void; + infoArchive(options: {}): Promise; /** @param file Filename (will read synchronously), Buffer or stream */ putArchive(file: string | Buffer | NodeJS.ReadableStream, options: {}, callback: Callback): void; + putArchive(file: string | Buffer | NodeJS.ReadableStream, options: {}): Promise; - logs(options: { stdout?: boolean, stderr?: boolean, follow?: boolean, since?: number, details?: boolean, tail?: number, timestamps?: boolean }, callback: Callback): void; + logs(options: ContainerLogsOptions, callback: Callback): void; logs(callback: Callback): void; + logs(options?: ContainerLogsOptions): Promise; stats(options: {}, callback: Callback): void; stats(callback: Callback): void; + stats(options?: {}): Promise; attach(options: {}, callback: Callback): void; + attach(options: {}): Promise; modem: any; id?: string; @@ -82,19 +106,25 @@ declare namespace Dockerode { interface Image { inspect(callback: Callback): void; + inspect(): Promise; history(callback: Callback): void; + history(): Promise; get(callback: Callback): void; + get(): Promise; push(options: {}, callback: Callback): void; push(callback: Callback): void; + push(options?: {}): Promise; tag(options: {}, callback: Callback): void; tag(callback: Callback): void; + tag(options?: {}): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; modem: any; id?: string; @@ -102,9 +132,11 @@ declare namespace Dockerode { interface Volume { inspect(callback: Callback): void; + inspect(): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; modem: any; name?: string; @@ -112,11 +144,14 @@ declare namespace Dockerode { interface Service { inspect(callback: Callback): void; + inspect(): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; update(options: {}, callback: Callback): void; + update(options: {}): Promise; modem: any; id?: string; @@ -124,6 +159,7 @@ declare namespace Dockerode { interface Task { inspect(callback: Callback): void; + inspect(): Promise; modem: any; id?: string; @@ -131,6 +167,7 @@ declare namespace Dockerode { interface Node { inspect(callback: Callback): void; + inspect(): Promise; modem: any; id?: string; @@ -142,38 +179,50 @@ declare namespace Dockerode { remote: any; inspect(callback: Callback): void; + inspect(): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; privileges(callback: Callback): void; + privileges(): Promise; pull(options: {}, callback: Callback): void; + pull(options: {}): Promise; enable(options: {}, callback: Callback): void; enable(callback: Callback): void; + enable(options?: {}): Promise; disable(options: {}, callback: Callback): void; disable(callback: Callback): void; + disable(options?: {}): Promise; push(options: {}, callback: Callback): void; push(callback: Callback): void; + push(options?: {}): Promise; configure(options: {}, callback: Callback): void; configure(callback: Callback): void; + configure(options?: {}): Promise; upgrade(auth: any, options: {}, callback: Callback): void; upgrade(auth: any, callback: Callback): void; + upgrade(auth: any, options?: {}): Promise; } interface Secret { inspect(callback: Callback): void; + inspect(): Promise; update(options: {}, callback: Callback): void; update(callback: Callback): void; + update(options?: {}): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; modem: any; id?: string; @@ -181,15 +230,19 @@ declare namespace Dockerode { interface Network { inspect(callback: Callback): void; + inspect(): Promise; remove(options: {}, callback: Callback): void; remove(callback: Callback): void; + remove(options?: {}): Promise; connect(options: {}, callback: Callback): void; connect(callback: Callback): void; + connect(options?: {}): Promise; disconnect(options: {}, callback: Callback): void; disconnect(callback: Callback): void; + disconnect(options?: {}): Promise; modem: any; id?: string; @@ -197,10 +250,13 @@ declare namespace Dockerode { interface Exec { inspect(callback: Callback): void; + inspect(): Promise; start(options: {}, callback: Callback): void; + start(options: {}): Promise; resize(options: {}, callback: Callback): void; + resize(options: {}): Promise; modem: any; id?: string; @@ -587,6 +643,7 @@ declare namespace Dockerode { key?: string; protocol?: "https" | "http"; timeout?: number; + Promise?: typeof Promise; } interface SecretVersion { @@ -719,6 +776,16 @@ declare namespace Dockerode { interface PruneNetworksInfo { NetworksDeleted: string[]; } + + interface ContainerLogsOptions { + stdout?: boolean; + stderr?: boolean; + follow?: boolean; + since?: number; + details?: boolean; + tail?: number; + timestamps?: boolean; + } } type Callback = (error?: any, result?: T) => void; @@ -727,20 +794,27 @@ declare class Dockerode { constructor(options?: Dockerode.DockerOptions); createContainer(options: Dockerode.ContainerCreateOptions, callback: Callback): void; + createContainer(options: Dockerode.ContainerCreateOptions): Promise; createImage(options: {}, callback: Callback): void; createImage(auth: any, options: {}, callback: Callback): void; + createImage(options: {}): Promise; + createImage(auth: any, options: {}): Promise; loadImage(file: string, options: {}, callback: Callback): void; loadImage(file: string, callback: Callback): void; + loadImage(file: string, options?: {}): Promise; importImage(file: string, options: {}, callback: Callback): void; importImage(file: string, callback: Callback): void; + importImage(file: string, options?: {}): Promise; checkAuth(options: any, callback: Callback): void; + checkAuth(options: any): Promise; buildImage(file: string | NodeJS.ReadableStream, options: {}, callback: Callback): void; buildImage(file: string | NodeJS.ReadableStream, callback: Callback): void; + buildImage(file: string | NodeJS.ReadableStream, options?: {}): Promise; getContainer(id: string): Dockerode.Container; @@ -764,80 +838,110 @@ declare class Dockerode { listContainers(options: {}, callback: Callback): void; listContainers(callback: Callback): void; + listContainers(options?: {}): Promise; listImages(options: {}, callback: Callback): void; listImages(callback: Callback): void; + listImages(options?: {}): Promise; listServices(options: {}, callback: Callback): void; listServices(callback: Callback): void; + listServices(options?: {}): Promise; listNodes(options: {}, callback: Callback): void; listNodes(callback: Callback): void; + listNodes(options?: {}): Promise; listTasks(options: {}, callback: Callback): void; listTasks(callback: Callback): void; + listTasks(options?: {}): Promise; listSecrets(options: {}, callback: Callback): void; listSecrets(callback: Callback): void; + listSecrets(options?: {}): Promise; listPlugins(options: {}, callback: Callback): void; listPlugins(callback: Callback): void; + listPlugins(options?: {}): Promise; listVolumes(options: {}, callback: Callback): void; listVolumes(callback: Callback): void; + listVolumes(options?: {}): Promise; listNetworks(options: {}, callback: Callback): void; listNetworks(callback: Callback): void; + listNetworks(options?: {}): Promise; createSecret(options: {}, callback: Callback): void; + createSecret(options: {}): Promise; createPlugin(options: {}, callback: Callback): void; + createPlugin(options: {}): Promise; createVolume(options: {}, callback: Callback): void; + createVolume(options: {}): Promise; createService(options: {}, callback: Callback): void; + createService(options: {}): Promise; createNetwork(options: {}, callback: Callback): void; + createNetwork(options: {}): Promise; searchImages(options: {}, callback: Callback): void; + searchImages(options: {}): Promise; pruneImages(options: {}, callback: Callback): void; pruneImages(callback: Callback): void; + pruneImages(options?: {}): Promise; pruneContainers(options: {}, callback: Callback): void; pruneContainers(callback: Callback): void; + pruneContainers(options?: {}): Promise; pruneVolumes(options: {}, callback: Callback): void; pruneVolumes(callback: Callback): void; + pruneVolumes(options?: {}): Promise; pruneNetworks(options: {}, callback: Callback): void; pruneNetworks(callback: Callback): void; + pruneNetworks(options?: {}): Promise; info(callback: Callback): void; + info(): Promise; version(callback: Callback): void; + version(): Promise; ping(callback: Callback): void; + ping(): Promise; getEvents(options: {}, callback: Callback): void; getEvents(callback: Callback): void; + getEvents(options?: {}): Promise; pull(repoTag: string, options: {}, callback: Callback, auth?: {}): Dockerode.Image; + pull(repoTag: string, options: {}, auth?: {}): Promise; run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, createOptions: {}, startOptions: {}, callback: Callback): events.EventEmitter; run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, startOptions: {}, callback: Callback): events.EventEmitter; run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, callback: Callback): events.EventEmitter; run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, createOptions: {}, callback: Callback): events.EventEmitter; + run(image: string, cmd: string[], outputStream: NodeJS.WritableStream, createOptions?: {}, startOptions?: {}): Promise; swarmInit(options: {}, callback: Callback): void; + swarmInit(options: {}): Promise; swarmJoin(options: {}, callback: Callback): void; + swarmJoin(options: {}): Promise; swarmLeave(options: {}, callback: Callback): void; + swarmLeave(options: {}): Promise; swarmUpdate(options: {}, callback: Callback): void; + swarmUpdate(options: {}): Promise; swarmInspect(callback: Callback): void; + swarmInspect(): Promise; modem: any; } diff --git a/types/dockerode/tsconfig.json b/types/dockerode/tsconfig.json index 2a83a71968..8f360ab29a 100644 --- a/types/dockerode/tsconfig.json +++ b/types/dockerode/tsconfig.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "target": "es6", "module": "commonjs", "lib": [ "es6" From b57178eb88343bd778f4c29424c450ba3d93e166 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 6 May 2017 02:32:09 +1000 Subject: [PATCH 30/50] material-ui: Updated width prop of drawer to be compliant with spec (#16342) * material-ui: Updated width prop of drawer to be compliant with spec * update header --- types/material-ui/index.d.ts | 4 ++-- types/material-ui/material-ui-tests.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index ce98d40903..47c124595e 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for material-ui v0.17.5 +// Type definitions for material-ui v0.17.51 // Project: https://github.com/callemall/material-ui // Definitions by: Nathan Brown , Igor Belagorudsky , Ali Taheri Moghaddar , Oliver Herrmann , Daniel Roth , Aurelién Allienne // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -1019,7 +1019,7 @@ declare namespace __MaterialUI { overlayStyle?: React.CSSProperties; style?: React.CSSProperties; swipeAreaWidth?: number; - width?: number; + width?: number | string; zDepth?: number; } export class Drawer extends React.Component { diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index 87908cd6ec..a0d8d32d92 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -1662,7 +1662,7 @@ class DrawerOpenRightExample extends React.Component<{}, {open?: boolean}> { label="Toggle Drawer" onTouchTap={this.handleToggle} /> - + From dd69d6de4ed71c2eecd08a76189f00db504053fd Mon Sep 17 00:00:00 2001 From: rasmusvhansen Date: Fri, 5 May 2017 18:36:05 +0200 Subject: [PATCH 31/50] class_ argument is optional in removeLineClass (#16347) --- types/codemirror/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 561d311540..9a74dc1e53 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -178,7 +178,7 @@ declare namespace CodeMirror { /** Remove a CSS class from a line.line can be a line handle or number. where should be one of "text", "background", or "wrap"(see addLineClass). class can be left off to remove all classes for the specified node, or be a string to remove only a specific class. */ - removeLineClass(line: any, where: string, class_: string): CodeMirror.LineHandle; + removeLineClass(line: any, where: string, class_?: string): CodeMirror.LineHandle; /** * Compute the line at the given pixel height. From 73bcc6d987c05401cd0c6df3eb46150e20156b48 Mon Sep 17 00:00:00 2001 From: delphinus Date: Sat, 6 May 2017 01:36:26 +0900 Subject: [PATCH 32/50] [backbone.marionette] Add lacked methods to marionette view (#16348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add lacked / fix wrong definition of methods * Add tests for added methods⏎ --- types/backbone.marionette/backbone.marionette-tests.ts | 8 ++++++++ types/backbone.marionette/index.d.ts | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/types/backbone.marionette/backbone.marionette-tests.ts b/types/backbone.marionette/backbone.marionette-tests.ts index 46f504e18e..a7da55495b 100644 --- a/types/backbone.marionette/backbone.marionette-tests.ts +++ b/types/backbone.marionette/backbone.marionette-tests.ts @@ -292,6 +292,14 @@ function RegionTests() { } +function ViewTests() { + const v = new MyView(new MyModel()); + const isDestroyed: boolean = v.isDestroyed(); + const isRendered: boolean = v.isRendered(); + const isAttached: boolean = v.isAttached(); + const vv: Marionette.View = v.delegateEntityEvents(); +} + function CollectionViewTests() { var cv = new MyCollectionView(); cv.collection.add(new MyModel()); diff --git a/types/backbone.marionette/index.d.ts b/types/backbone.marionette/index.d.ts index d24f9d64f9..93b82355db 100644 --- a/types/backbone.marionette/index.d.ts +++ b/types/backbone.marionette/index.d.ts @@ -856,7 +856,10 @@ declare namespace Marionette { /** * Internal properties extended in Marionette.View. */ - isDestroyed: boolean; + isDestroyed(): boolean; + isRendered(): boolean; + isAttached(): boolean; + delegateEntityEvents(): View; supportsRenderLifecycle: boolean; supportsDestroyLifecycle: boolean; From 942dcf66e2d1743748ae32ab0fa3c4647ca385bb Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 5 May 2017 19:55:15 +0300 Subject: [PATCH 33/50] [sequelize] add force option for TruncateOptions (#16353) --- types/sequelize/v3/index.d.ts | 9 ++++++++- types/sequelize/v3/sequelize-tests.ts | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index 3712c4fb56..a02ba7d0ed 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -3211,7 +3211,7 @@ declare namespace sequelize { * https://github.com/sequelize/sequelize/blob/master/docs/docs/models-usage.md#user-content-manipulating-the-dataset-with-limit-offset-order-and-group */ group?: string | string[] | Object; - + /** * Apply DISTINCT(col) for FindAndCount(all) */ @@ -3371,6 +3371,13 @@ declare namespace sequelize { * Defaults to false; */ cascade?: boolean; + + /** + * Delete instead of setting deletedAt to current timestamp (only applicable if paranoid is enabled) + * + * Defaults to false; + */ + force?: boolean; } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 83c4536a71..3e972d3119 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -992,6 +992,9 @@ User.bulkCreate( [{ name : 'foo', code : '123' }, { code : '1234' }], { fields : User.bulkCreate( [{ name : 'a', c : 'b' }, { name : 'e', c : 'f' }], { fields : ['e', 'f'], ignoreDuplicates : true } ); User.truncate(); +User.truncate( { cascade : true } ); +User.truncate( { force : true } ); +User.truncate( { cascade: true, force : true } ); User.destroy( { where : { client_id : 13 } } ).then( ( a ) => a.toFixed() ); User.destroy( { force : true } ); From 221fdba61bae4892225528f4ef2af1ea9ab8f5a8 Mon Sep 17 00:00:00 2001 From: yuche Date: Sat, 6 May 2017 01:11:00 +0800 Subject: [PATCH 34/50] add `extraData` prop to FlatList and SectionList (#16338) * add `extraData` prop to FlatList and SectionList see: https://facebook.github.io/react-native/docs/sectionlist.html#props https://facebook.github.io/react-native/docs/flatlist.html#props * remove extra space --- types/react-native/index.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 5fd5b40b96..7a02b28e6b 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3435,6 +3435,13 @@ export interface FlatListProperties { */ data: ItemT[] | null; + /** + * A marker property for telling the list to re-render (since it implements PureComponent). + * If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop, + * stick it here and treat it immutably. + */ + extraData?: any + /** * `getItemLayout` is an optional optimization that lets us skip measurement of dynamic * content if you know the height of items a priori. getItemLayout is the most efficient, @@ -3598,6 +3605,13 @@ export interface SectionListProperties extends ScrollViewProperties { */ SectionSeparatorComponent?: React.ComponentClass | null + /** + * A marker property for telling the list to re-render (since it implements PureComponent). + * If any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the `data` prop, + * stick it here and treat it immutably. + */ + extraData?: any + /** * Used to extract a unique key for a given item at the specified index. Key is used for caching * and as the react key to track item re-ordering. The default extractor checks `item.key`, then From 585178525c00f19e930516caaf90ecc5acbe50f0 Mon Sep 17 00:00:00 2001 From: DaIgeb Date: Fri, 5 May 2017 19:11:16 +0200 Subject: [PATCH 35/50] Update SwitchProps to support typescript 2.3 (#16340) SwitchProps.children is too strict for projects using typescript 2.3. With typescript 2.3 the children could be made mandatory, but this will break backwards compatibility with any ts 2.2 user --- types/react-router/index.d.ts | 3 ++- types/react-router/test/Switch.tsx | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 81244caa29..a955271aae 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -12,6 +12,7 @@ // Tanguy Krotoff // Huy Nguyen // Jérémy Fauvel +// Daniel Roth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -84,7 +85,7 @@ export interface StaticRouterProps { export class StaticRouter extends React.Component {} export interface SwitchProps { - children?: JSX.Element | JSX.Element[]; + children?: React.ReactNode; location?: H.Location; } export class Switch extends React.Component {} diff --git a/types/react-router/test/Switch.tsx b/types/react-router/test/Switch.tsx index 6a8b50f247..fe959504ce 100644 --- a/types/react-router/test/Switch.tsx +++ b/types/react-router/test/Switch.tsx @@ -2,12 +2,18 @@ import * as React from 'react'; import { BrowserRouter, Redirect, Route, Switch } from 'react-router-dom'; const Home = () =>

Home

; +const About = () =>

About

; +const User = () =>

User

; const SwitchTest = () => ( + {[ + , + + ]} ); From fe1b612ef0d9ffd45114431adac61b5e6ee1173f Mon Sep 17 00:00:00 2001 From: DaIgeb Date: Fri, 5 May 2017 19:38:55 +0200 Subject: [PATCH 36/50] Allow component props for withRouter (#16339) --- types/react-router/index.d.ts | 16 ++++++++-------- types/react-router/test/WithRouter.tsx | 14 ++++++++++++++ types/react-router/tsconfig.json | 3 ++- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 types/react-router/test/WithRouter.tsx diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index a955271aae..43fe16f484 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -37,13 +37,13 @@ export interface MemoryRouterProps { keyLength?: number; } -export class MemoryRouter extends React.Component {} +export class MemoryRouter extends React.Component { } export interface PromptProps { message: string | ((location: H.Location) => void); when?: boolean; } -export class Prompt extends React.Component {} +export class Prompt extends React.Component { } export interface RedirectProps { to: H.LocationDescriptor; @@ -53,7 +53,7 @@ export interface RedirectProps { exact?: boolean; strict?: boolean; } -export class Redirect extends React.Component {} +export class Redirect extends React.Component { } export interface RouteComponentProps

{ match: match

; @@ -70,12 +70,12 @@ export interface RouteProps { exact?: boolean; strict?: boolean; } -export class Route extends React.Component {} +export class Route extends React.Component { } export interface RouterProps { history: any; } -export class Router extends React.Component {} +export class Router extends React.Component { } export interface StaticRouterProps { basename?: string; @@ -83,12 +83,12 @@ export interface StaticRouterProps { context?: object; } -export class StaticRouter extends React.Component {} +export class StaticRouter extends React.Component { } export interface SwitchProps { children?: React.ReactNode; location?: H.Location; } -export class Switch extends React.Component {} +export class Switch extends React.Component { } export interface match

{ params: P; @@ -98,4 +98,4 @@ export interface match

{ } export function matchPath

(pathname: string, props: RouteProps): match

| null; -export function withRouter(component: React.SFC> | React.ComponentClass>): React.ComponentClass; +export function withRouter

(component: React.SFC & P> | React.ComponentClass & P>): React.ComponentClass

; diff --git a/types/react-router/test/WithRouter.tsx b/types/react-router/test/WithRouter.tsx new file mode 100644 index 0000000000..72035ed92f --- /dev/null +++ b/types/react-router/test/WithRouter.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import { withRouter, RouteComponentProps } from 'react-router-dom'; + +interface TOwnProps { + username: string; +} + +const Component = (props: TOwnProps & RouteComponentProps<{}>) =>

Welcome {props.username}

; + +const WithRouterComponent = withRouter(Component); + +const WithRouterTest = () => (); + +export default WithRouterTest; diff --git a/types/react-router/tsconfig.json b/types/react-router/tsconfig.json index 3a2e475777..df074843df 100644 --- a/types/react-router/tsconfig.json +++ b/types/react-router/tsconfig.json @@ -28,6 +28,7 @@ "test/Recursive.tsx", "test/RouteConfig.tsx", "test/Sidebar.tsx", - "test/Switch.tsx" + "test/Switch.tsx", + "test/WithRouter.tsx" ] } From d8b7da2042b57355dc929b6511032272e9c4f18b Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 5 May 2017 16:20:09 -0700 Subject: [PATCH 37/50] Fix for getTypeMap() return type in graphql schema.d.ts. (#16343) --- types/graphql/type/schema.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/graphql/type/schema.d.ts b/types/graphql/type/schema.d.ts index 5a2cdd0af4..0f02cd78af 100644 --- a/types/graphql/type/schema.d.ts +++ b/types/graphql/type/schema.d.ts @@ -51,7 +51,7 @@ export class GraphQLSchema { getQueryType(): GraphQLObjectType; getMutationType(): GraphQLObjectType; getSubscriptionType(): GraphQLObjectType; - getTypeMap(): GraphQLNamedType; + getTypeMap(): { [typeName: string]: GraphQLNamedType }; getType(name: string): GraphQLType; getPossibleTypes(abstractType: GraphQLAbstractType): Array; From 24f2ff899f4b5972f9464ebadf0ec103897fb952 Mon Sep 17 00:00:00 2001 From: ikokostya Date: Sat, 6 May 2017 02:20:41 +0300 Subject: [PATCH 38/50] @types/node: Port dns.resolve* changes #16320 to node.js 4, 6 (#16350) * @types/node: Port dns.resolve* changes #16320 to node.js 4, 6 * review fixes --- types/node/v4/index.d.ts | 102 ++++++++++++++++++++++++++++++------ types/node/v4/node-tests.ts | 21 ++++++++ types/node/v6/index.d.ts | 81 +++++++++++++++++++++------- types/node/v6/node-tests.ts | 21 ++++++++ 4 files changed, 190 insertions(+), 35 deletions(-) diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 8d32f09744..c74f8dcb0b 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -1265,22 +1265,94 @@ declare module "dns" { family: number; } - export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; - export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; - export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; + export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; + export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; + export interface MxRecord { + priority: number; + exchange: string; + } + + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + + export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void; + export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void; + + export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void; + export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + + export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; + export function setServers(servers: string[]): void; + + //Error codes + export var NODATA: string; + export var FORMERR: string; + export var SERVFAIL: string; + export var NOTFOUND: string; + export var NOTIMP: string; + export var REFUSED: string; + export var BADQUERY: string; + export var BADNAME: string; + export var BADFAMILY: string; + export var BADRESP: string; + export var CONNREFUSED: string; + export var TIMEOUT: string; + export var EOF: string; + export var FILE: string; + export var NOMEM: string; + export var DESTRUCTION: string; + export var BADSTR: string; + export var BADFLAGS: string; + export var NONAME: string; + export var BADHINTS: string; + export var NOTINITIALIZED: string; + export var LOADIPHLPAPI: string; + export var ADDRGETNETWORKPARAMS: string; + export var CANCELLED: string; } declare module "net" { diff --git a/types/node/v4/node-tests.ts b/types/node/v4/node-tests.ts index 43ce0f9f42..5274116452 100644 --- a/types/node/v4/node-tests.ts +++ b/types/node/v4/node-tests.ts @@ -1021,4 +1021,25 @@ namespace dns_tests { const _addresses: string | dns.LookupAddress[] = addresses; const _family: number | undefined = family; }); + + dns.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "A", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "AAAA", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "MX", (err, addresses) => { + const _addresses: dns.MxRecord[] = addresses; + }); + + dns.resolve4("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + + dns.resolve6("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); } diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index 664a037dd9..ebc2b516d6 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -1807,11 +1807,6 @@ declare module "url" { } declare module "dns" { - export interface MxRecord { - exchange: string, - priority: number - } - // Supported getaddrinfo flags. export const ADDRCONFIG: number; export const V4MAPPED: number; @@ -1835,22 +1830,68 @@ declare module "dns" { family: number; } - export function lookup(domain: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function lookup(domain: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; - export function lookup(domain: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; - export function lookup(domain: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; + export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException, addresses: LookupAddress[]) => void): void; + export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException, address: string | LookupAddress[], family: number) => void): void; + export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException, address: string, family: number) => void): void; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: MxRecord[]) => void): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) => void): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) => void): string[]; + export interface MxRecord { + priority: number; + exchange: string; + } + + export interface NaptrRecord { + flags: string; + service: string; + regexp: string; + replacement: string; + order: number; + preference: number; + } + + export interface SoaRecord { + nsname: string; + hostmaster: string; + serial: number; + refresh: number; + retry: number; + expire: number; + minttl: number; + } + + export interface SrvRecord { + priority: number; + weight: number; + port: number; + name: string; + } + + export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "A", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "AAAA", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "CNAME", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "MX", callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NAPTR", callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "NS", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "PTR", callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve(hostname: string, rrtype: "SOA", callback: (err: NodeJS.ErrnoException, addresses: SoaRecord) => void): void; + export function resolve(hostname: string, rrtype: "SRV", callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolve(hostname: string, rrtype: "TXT", callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + export function resolve(hostname: string, rrtype: string, callback: (err: NodeJS.ErrnoException, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][]) => void): void; + + export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: MxRecord[]) => void): void; + export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: NaptrRecord[]) => void): void; + export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[]) => void): void; + export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException, address: SoaRecord) => void): void; + export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: SrvRecord[]) => void): void; + export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException, addresses: string[][]) => void): void; + + export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void; export function setServers(servers: string[]): void; //Error codes diff --git a/types/node/v6/node-tests.ts b/types/node/v6/node-tests.ts index 4792c5edf1..b2ca08898c 100644 --- a/types/node/v6/node-tests.ts +++ b/types/node/v6/node-tests.ts @@ -2091,6 +2091,27 @@ namespace dns_tests { const _addresses: string | dns.LookupAddress[] = addresses; const _family: number | undefined = family; }); + + dns.resolve("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "A", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "AAAA", (err, addresses) => { + const _addresses: string[] = addresses; + }); + dns.resolve("nodejs.org", "MX", (err, addresses) => { + const _addresses: dns.MxRecord[] = addresses; + }); + + dns.resolve4("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); + + dns.resolve6("nodejs.org", (err, addresses) => { + const _addresses: string[] = addresses; + }); } /***************************************************************************** From da3ab04e728d7bbc05ae7a94119e31c1d8b13171 Mon Sep 17 00:00:00 2001 From: Daryl LaBar Date: Fri, 5 May 2017 19:21:56 -0400 Subject: [PATCH 39/50] Defined interfaces for Properties and Fixed Linting issues (#16355) * Updated XrmStatic Properties Page, Utility, and Panel to match the pattern that Mobil was doing, and be defined as interfaces. This also makes allows for variables to easily be tyepd i.e. var p: Xrm.Page. Also retyped getInitalValue for booleans and OptionsetValues to be their correct respective types. * Fixed Linitng issues and fixed header so it could be parsed by the DT Bot * Fixed Other Lint-ing Issues. Not sure what to do about the header being unparsable. Added commas, maybe that will help? --- types/xrm/index.d.ts | 430 ++++++++++++++++++++++------------------- types/xrm/xrm-tests.ts | 2 +- 2 files changed, 228 insertions(+), 204 deletions(-) diff --git a/types/xrm/index.d.ts b/types/xrm/index.d.ts index 956dc969a2..6e6a1d5117 100644 --- a/types/xrm/index.d.ts +++ b/types/xrm/index.d.ts @@ -1,9 +1,9 @@ // Type definitions for Microsoft Dynamics xRM API 8.2 // Project: http://www.microsoft.com/en-us/download/details.aspx?id=44567 -// Definitions by: David Berry -// Matt Ngan -// Markus Mauch -// Daryl LaBar +// Definitions by: David Berry , +// Matt Ngan , +// Markus Mauch , +// Daryl LaBar , // Tully H // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -24,198 +24,12 @@ declare namespace Xrm { /** * Provides a namespace container for the context, data and ui objects. */ - Page: { - /** - * Provides methods to retrieve information specific to an organization, a user, or parameters passed to a page. - */ - context: Context; - - /** - * Provides methods to work with the form. - */ - data: Data; - - /** - * Contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form. - */ - ui: Ui; - - /** - * Gets all attributes. - * - * @return An array of attributes. - */ - getAttribute(): Page.Attribute[]; - - /** - * Gets an attribute matching attributeName. - * - * @tparam T An Attribute type. - * @param {string} attributeName Name of the attribute. - * - * @return The attribute. - */ - getAttribute(attributeName: string): T; - - /** - * Gets an attribute matching attributeName. - * - * @param {string} attributeName Name of the attribute. - * - * @return The attribute. - */ - getAttribute(attributeName: string): Page.Attribute; - - /** - * Gets an attribute by index. - * - * @param {number} index The attribute index. - * - * @return The attribute. - */ - getAttribute(index: number): Page.Attribute; - - /** - * Gets an attribute. - * - * @param {Collection.MatchingDelegate{Attribute}} delegateFunction A matching delegate function - * - * @return An array of attribute. - */ - getAttribute(delegateFunction: Collection.MatchingDelegate): Page.Attribute[]; - - /** - * Gets all controls. - * - * @return An array of controls. - */ - getControl(): Page.Control[]; - - /** - * Gets a control matching controlName. - * - * @tparam T A Control type - * @param {string} controlName Name of the control. - * - * @return The control. - */ - getControl(controlName: string): T; - - /** - * Gets a control matching controlName. - * - * @param {string} controlName Name of the control. - * - * @return The control. - */ - getControl(controlName: string): Page.Control; - - /** - * Gets a control by index. - * - * @tparam T A Control type - * @param {number} index The control index. - * - * @return The control. - */ - getControl(index: number): T; - - /** - * Gets a control by index. - * - * @param {number} index The control index. - * - * @return The control. - */ - getControl(index: number): Page.Control; - - /** - * Gets a control. - * - * @param {Collection.MatchingDelegate{Control}} delegateFunction A matching delegate function. - * - * @return An array of control. - */ - getControl(delegateFunction: Collection.MatchingDelegate): Page.Control[]; - }; + Page: Page; /** * Provides a container for useful functions not directly related to the current page. */ - Utility: { - /** - * Displays an alert dialog, with an "OK" button. - * - * @param {string} message The message. - * @param {function()} onCloseCallback The "OK" callback. - */ - alertDialog(message: string, onCloseCallback: () => void): void; - - /** - * Displays a confirmation dialog, with "OK" and "Cancel" buttons. - * - * @param {string} message The message. - * @param {function()} yesCloseCallback The "OK" callback. - * @param {function()} noCloseCallback The "Cancel" callback. - */ - confirmDialog(message: string, yesCloseCallback: () => void, noCloseCallback: () => void): void; - - /** - * Query if 'entityType' is an Activity entity. - * - * @param {string} entityType Type of the entity. - * - * @return true if the entity is an Activity, false if not. - */ - isActivityType(entityType: string): boolean; - - /** - * Opens quick create. - * - * @param {string} entityLogicalName The logical name of the entity to create. - * @param {Page.LookupValue} createFromEntity (Optional) Designates a record that will provide default values - * based on mapped attribute values. - * @param {OpenParameters} parameters (Optional) A dictionary object that passes extra query string - * parameters to the form. Invalid query string parameters will cause an - * error. - * @return {Async.XrmPromise} Returns an asynchronous promise. - */ - openQuickCreate(entityLogicalName: string, createFromEntity?: Page.LookupValue, parameters?: Utility.OpenParameters): - Async.XrmPromise; - - /** - * Opens an entity form. - * - * @param {string} name The entity's logical name. - * @param {string} id (Optional) The unique identifier for the record. - * @param {FormParameters} parameters (Optional) A dictionary object that passes extra query string parameters to the form. - * @param {WindowOptions} windowOptions (Optional) Options for controlling the window. - */ - openEntityForm(name: string, id?: string, parameters?: Utility.FormOpenParameters, windowOptions?: Utility.WindowOptions): void; - - /** - * Opens an HTML Web Resource in a new browser window. - * - * @param {string} webResourceName Name of the HTML web resource. Can be used to pass URL - * parameters. See Remarks. - * @param {string} webResourceData (Optional) Data to pass into the Web Resource's data parameter. - * It is advised to use encodeURIcomponent() to encode the value. - * @param {number} width (Optional) The width of the new window. - * @param {number} height (Optional) The height of the new window. - * - * @return A Window reference, containing the opened Web Resource. - * - * @remarks This function will not work with Microsoft Dynamics CRM for tablets. - * Valid WebResource URL Parameters: typename - * type - * id - * orgname - * userlcid - * data (identical to this method's webResourceData parameter) - * formid - */ - openWebResource(webResourceName: string, webResourceData?: string, width?: number, height?: number): Window; - }; + Utility: Utility; /** * Provides methods to create and manage records in the mobile clients (for phones tablets). @@ -227,17 +41,7 @@ declare namespace Xrm { * * @see {@link https://msdn.microsoft.com/en-us/library/mt790281.aspx} for details. */ - Panel: { - /** - * Displays the web page represented by a URL in the static area in the side pane, which appears on all pages in the web client. - * - * @param {string} url URL of the page to be loaded in the side pane static area. - * @param {string} url Title of the side pane static area. - * - * @remarks This method is only supported for the web client. - */ - LoadPanel(url: string, title: string): void; - }; + Panel: Panel; } /** @@ -443,6 +247,121 @@ declare namespace Xrm { process: Page.data.ProcessManager; } + interface Page { + /** + * Provides methods to retrieve information specific to an organization, a user, or parameters passed to a page. + */ + context: Context; + + /** + * Provides methods to work with the form. + */ + data: Data; + + /** + * Contains properties and methods to retrieve information about the user interface as well as collections for several subcomponents of the form. + */ + ui: Ui; + + /** + * Gets all attributes. + * + * @return An array of attributes. + */ + getAttribute(): Page.Attribute[]; + + /** + * Gets an attribute matching attributeName. + * + * @tparam T An Attribute type. + * @param {string} attributeName Name of the attribute. + * + * @return The attribute. + */ + getAttribute(attributeName: string): T; + + /** + * Gets an attribute matching attributeName. + * + * @param {string} attributeName Name of the attribute. + * + * @return The attribute. + */ + getAttribute(attributeName: string): Page.Attribute; + + /** + * Gets an attribute by index. + * + * @param {number} index The attribute index. + * + * @return The attribute. + */ + getAttribute(index: number): Page.Attribute; + + /** + * Gets an attribute. + * + * @param {Collection.MatchingDelegate{Attribute}} delegateFunction A matching delegate function + * + * @return An array of attribute. + */ + getAttribute(delegateFunction: Collection.MatchingDelegate): Page.Attribute[]; + + /** + * Gets all controls. + * + * @return An array of controls. + */ + getControl(): Page.Control[]; + + /** + * Gets a control matching controlName. + * + * @tparam T A Control type + * @param {string} controlName Name of the control. + * + * @return The control. + */ + getControl(controlName: string): T; + + /** + * Gets a control matching controlName. + * + * @param {string} controlName Name of the control. + * + * @return The control. + */ + getControl(controlName: string): Page.Control; + + /** + * Gets a control by index. + * + * @tparam T A Control type + * @param {number} index The control index. + * + * @return The control. + */ + getControl(index: number): T; + + /** + * Gets a control by index. + * + * @param {number} index The control index. + * + * @return The control. + */ + getControl(index: number): Page.Control; + + /** + * Gets a control. + * + * @param {Collection.MatchingDelegate{Control}} delegateFunction A matching delegate function. + * + * @return An array of control. + */ + getControl(delegateFunction: Collection.MatchingDelegate): Page.Control[]; + } + /** * Interface for the Xrm.Page.ui object. */ @@ -552,6 +471,81 @@ declare namespace Xrm { quickForms: Collection.ItemCollection; } + interface Utility { + /** + * Displays an alert dialog, with an "OK" button. + * + * @param {string} message The message. + * @param {function()} onCloseCallback The "OK" callback. + */ + alertDialog(message: string, onCloseCallback: () => void): void; + + /** + * Displays a confirmation dialog, with "OK" and "Cancel" buttons. + * + * @param {string} message The message. + * @param {function()} yesCloseCallback The "OK" callback. + * @param {function()} noCloseCallback The "Cancel" callback. + */ + confirmDialog(message: string, yesCloseCallback: () => void, noCloseCallback: () => void): void; + + /** + * Query if 'entityType' is an Activity entity. + * + * @param {string} entityType Type of the entity. + * + * @return true if the entity is an Activity, false if not. + */ + isActivityType(entityType: string): boolean; + + /** + * Opens quick create. + * + * @param {string} entityLogicalName The logical name of the entity to create. + * @param {Page.LookupValue} createFromEntity (Optional) Designates a record that will provide default values + * based on mapped attribute values. + * @param {OpenParameters} parameters (Optional) A dictionary object that passes extra query string + * parameters to the form. Invalid query string parameters will cause an + * error. + * @return {Async.XrmPromise} Returns an asynchronous promise. + */ + openQuickCreate(entityLogicalName: string, createFromEntity?: Page.LookupValue, parameters?: Utility.OpenParameters): + Async.XrmPromise; + + /** + * Opens an entity form. + * + * @param {string} name The entity's logical name. + * @param {string} id (Optional) The unique identifier for the record. + * @param {FormParameters} parameters (Optional) A dictionary object that passes extra query string parameters to the form. + * @param {WindowOptions} windowOptions (Optional) Options for controlling the window. + */ + openEntityForm(name: string, id?: string, parameters?: Utility.FormOpenParameters, windowOptions?: Utility.WindowOptions): void; + + /** + * Opens an HTML Web Resource in a new browser window. + * + * @param {string} webResourceName Name of the HTML web resource. Can be used to pass URL + * parameters. See Remarks. + * @param {string} webResourceData (Optional) Data to pass into the Web Resource's data parameter. + * It is advised to use encodeURIcomponent() to encode the value. + * @param {number} width (Optional) The width of the new window. + * @param {number} height (Optional) The height of the new window. + * + * @return A Window reference, containing the opened Web Resource. + * + * @remarks This function will not work with Microsoft Dynamics CRM for tablets. + * Valid WebResource URL Parameters: typename + * type + * id + * orgname + * userlcid + * data (identical to this method's webResourceData parameter) + * formid + */ + openWebResource(webResourceName: string, webResourceData?: string, width?: number, height?: number): Window; + } + /** * Interface for methods to create and manage records in the mobile clients (for phones tablets). */ @@ -666,6 +660,18 @@ declare namespace Xrm { deleteRecord(entityType: string, id: string): Async.XrmPromise; } + interface Panel { + /** + * Displays the web page represented by a URL in the static area in the side pane, which appears on all pages in the web client. + * + * @param {string} url URL of the page to be loaded in the side pane static area. + * @param {string} url Title of the side pane static area. + * + * @remarks This method is only supported for the web client. + */ + LoadPanel(url: string, title: string): void; + } + /** * A definition module for asynchronous interface declarations. */ @@ -1595,6 +1601,15 @@ declare namespace Xrm { * @sa EnumAttribute */ interface BooleanAttribute extends EnumAttribute { + /** + * Gets the initial value of the attribute. + * + * @return The initial value. + * + * @remarks Valid for OptionSet and boolean attribute types + */ + getInitialValue(): boolean; + /** * Gets the value. * @@ -1666,6 +1681,15 @@ declare namespace Xrm { */ getFormat(): OptionSetAttributeFormat; + /** + * Gets the initial value of the attribute. + * + * @return The initial value. + * + * @remarks Valid for OptionSet and boolean attribute types + */ + getInitialValue(): number; + /** * Gets the option matching a value. * diff --git a/types/xrm/xrm-tests.ts b/types/xrm/xrm-tests.ts index 5d9d99b644..5b5b12c333 100644 --- a/types/xrm/xrm-tests.ts +++ b/types/xrm/xrm-tests.ts @@ -143,7 +143,7 @@ const resultSet: Xrm.Page.AutoCompleteResultSet = { // accounts in CRM. window.open("http://www.microsoft.com/en-us/dynamics/crm-customer-center/create-or-edit-an-account.aspx"); } - } as Xrm.Page.AutoCompleteCommand + } }; resultSet.results.push({ id: 0, From c49e2aa150ef6c19d2f8e7c0b9ee7b98cb71a229 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 6 May 2017 02:22:36 +0300 Subject: [PATCH 40/50] [sequelize] add where option to DefineIndexesOptions (#16357) --- types/sequelize/v3/index.d.ts | 5 +++++ types/sequelize/v3/sequelize-tests.ts | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/types/sequelize/v3/index.d.ts b/types/sequelize/v3/index.d.ts index a02ba7d0ed..2f2f973c19 100644 --- a/types/sequelize/v3/index.d.ts +++ b/types/sequelize/v3/index.d.ts @@ -4757,6 +4757,11 @@ declare namespace sequelize { */ fields?: Array; + /** + * Condition for partioal index + */ + where?: WhereOptions; + } /** diff --git a/types/sequelize/v3/sequelize-tests.ts b/types/sequelize/v3/sequelize-tests.ts index 3e972d3119..9f5eac61ad 100644 --- a/types/sequelize/v3/sequelize-tests.ts +++ b/types/sequelize/v3/sequelize-tests.ts @@ -1261,7 +1261,7 @@ s.define( 'UserWithUniqueUsername', { username : { type : Sequelize.STRING, unique : { name : 'user_and_email', msg : 'User and email must be unique' } }, email : { type : Sequelize.STRING, unique : 'user_and_email' } } ); -/* NOTE https://github.com/DefinitelyTyped/DefinitelyTyped/pull/5590 + s.define( 'UserWithUniqueUsername', { user_id : { type : Sequelize.INTEGER }, email : { type : Sequelize.STRING } @@ -1269,13 +1269,15 @@ s.define( 'UserWithUniqueUsername', { indexes : [ { name : 'user_and_email_index', - msg : 'User and email must be unique', unique : true, method : 'BTREE', - fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }] + fields : ['user_id', { attribute : 'email', collate : 'en_US', order : 'DESC', length : 5 }], + where : { + user_id : { $not: null } + } }] } ); - */ + s.define( 'TaskBuild', { title : { type : Sequelize.STRING, defaultValue : 'a task!' }, foo : { type : Sequelize.INTEGER, defaultValue : 2 }, From 46eb9a8bfefd3d595e1f75290ea8848afde1cbed Mon Sep 17 00:00:00 2001 From: Adnan Chowdhury Date: Fri, 5 May 2017 16:23:05 -0700 Subject: [PATCH 41/50] Ember - Add additional type defs for RSVP namespace (#16359) * add additional type defs for RSVP * satisfy linting --- types/ember/index.d.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 37818e787e..201f14f156 100644 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Ember.js 2.7 // Project: http://emberjs.com/ // Definitions by: Jed Mao +// bttf // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -1571,6 +1572,34 @@ declare namespace Ember { @return {Promise} */ finally(callback: (a: T) => V, label?: string): Promise; + + static all(promises: GlobalArray<(Q | Thenable)>): Promise; + static race(promises: GlobalArray>): Promise; + + /** + @method resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static resolve(object?: Q | Thenable): Promise; + + /** + @method cast (Deprecated in favor of resolve + @param {Any} value value that the returned promise will be resolved with + @param {String} label optional string for identifying the returned promise. + Useful for tooling. + @return {Promise} a promise that will become fulfilled with the given + `value` + */ + static cast(object: Q | Thenable, label?: string): Promise; + + /** + `RSVP.Promise.reject` returns a promise rejected with the passed `reason`. + */ + static reject(reason?: any): Promise; } function all(promises: GlobalArray>): Promise; From 749652183e55518e244e4dc3822732d9d8662cf3 Mon Sep 17 00:00:00 2001 From: Joshua Netterfield Date: Fri, 5 May 2017 19:24:27 -0400 Subject: [PATCH 42/50] Types for react-monaco-editor@0.8 (#16360) --- types/react-monaco-editor/index.d.ts | 78 +++++++++ types/react-monaco-editor/package.json | 5 + .../react-monaco-editor-tests.tsx | 149 ++++++++++++++++++ types/react-monaco-editor/tsconfig.json | 24 +++ types/react-monaco-editor/tslint.json | 1 + 5 files changed, 257 insertions(+) create mode 100644 types/react-monaco-editor/index.d.ts create mode 100644 types/react-monaco-editor/package.json create mode 100644 types/react-monaco-editor/react-monaco-editor-tests.tsx create mode 100644 types/react-monaco-editor/tsconfig.json create mode 100644 types/react-monaco-editor/tslint.json diff --git a/types/react-monaco-editor/index.d.ts b/types/react-monaco-editor/index.d.ts new file mode 100644 index 0000000000..7f4a4a543e --- /dev/null +++ b/types/react-monaco-editor/index.d.ts @@ -0,0 +1,78 @@ +// Type definitions for react-monaco-editor 0.8 +// Project: https://github.com/superRaytin/react-monaco-editor +// Definitions by: Joshua Netterfield +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import * as React from "react"; + +export interface ReactMonacoEditorProps { + /** + * Width of editor. Defaults to 100%. + */ + width?: string | number; + + /** + * Height of editor. Defaults to 500. + */ + height?: string | number; + + /** + * Value of the auto created model in the editor. + * If you specify value property, the component behaves in controlled mode. Otherwise, it behaves in uncontrolled mode. + */ + value?: string; + + /** + * The initial value of the auto created model in the editor. + */ + defaultValue?: string; + + /** + * The initial language of the auto created model in the editor. + */ + language?: string; + + /** + * Theme to be used for rendering. + * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'. + * You can create custom themes via `monaco.editor.defineTheme`. + */ + theme?: string; + + /** + * Refer to Monaco interface IEditorOptions. + */ + options?: monaco.editor.IEditorOptions; + + /** + * An event emitted when the editor has been mounted (similar to componentDidMount of React). + */ + editorDidMount?(editor: monaco.editor.ICodeEditor, monacoModule: typeof monaco): void; + + /** + * An event emitted before the editor mounted (similar to componentWillMount of React). + */ + editorWillMount?(monacoModule: typeof monaco): void; + + /** + * An event emitted when the content of the current model has changed. + */ + onChange?(val: string, ev: monaco.editor.IModelContentChangedEvent2): void; + + /** + * Optional, allow to config loader url and relative path of module, refer to require.config. + */ + requireConfig?: object; + + /** + * Optional, allow to pass a different context then the global window onto which the monaco instance will be loaded. Useful if you want to load the editor in an iframe. + */ + context?: object; +} + +export default class ReactMonacoEditor extends React.Component { + editor: monaco.editor.ICodeEditor; +} diff --git a/types/react-monaco-editor/package.json b/types/react-monaco-editor/package.json new file mode 100644 index 0000000000..03bb1bd23d --- /dev/null +++ b/types/react-monaco-editor/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "monaco-editor": "0.8.3" + } +} diff --git a/types/react-monaco-editor/react-monaco-editor-tests.tsx b/types/react-monaco-editor/react-monaco-editor-tests.tsx new file mode 100644 index 0000000000..d8e8642bf9 --- /dev/null +++ b/types/react-monaco-editor/react-monaco-editor-tests.tsx @@ -0,0 +1,149 @@ +// Adapted from https://github.com/superRaytin/react-monaco-editor/blob/master/examples/index.js + +import * as React from 'react'; +import { render } from 'react-dom'; +import MonacoEditor from 'react-monaco-editor'; + +interface CodeEditorState { + code?: string; +} + +// Using with webpack +class CodeEditor extends React.Component { + constructor(props: object) { + super(props); + this.state = { + code: '// type your code... \n', + }; + } + editor: monaco.editor.ICodeEditor; + editorDidMount = (editor: monaco.editor.ICodeEditor) => { + console.log('editorDidMount', editor, editor.getValue(), editor.getModel()); + this.editor = editor; + } + onChange = (newValue: string, e: monaco.editor.IModelContentChangedEvent2) => { + console.log('onChange', newValue, e); + this.setState({ + code: newValue, + }); + } + changeEditorValue = () => { + if (this.editor) { + this.editor.setValue('// code changed! \n'); + } + } + changeBySetState = () => { + this.setState({code: '// code changed by setState! \n'}); + } + render() { + const code = this.state.code; + const options = { + selectOnLineNumbers: true, + roundedSelection: false, + readOnly: false, + theme: 'vs', + cursorStyle: 'line', + automaticLayout: false, + }; + return ( +
+
+ + +
+
+ +
+ ); + } +} + +// Using with require.config +class AnotherEditor extends React.Component { + constructor(props: object) { + super(props); + const jsonCode = [ + '{', + ' "$schema": "http://myserver/foo-schema.json"', + "}" + ].join('\n'); + this.state = { + code: jsonCode, + }; + } + editorWillMount = (monacoModule: typeof monaco) => { + monacoModule.languages.json.jsonDefaults.setDiagnosticsOptions({ + schemas: [{ + uri: "http://myserver/foo-schema.json", + schema: { + type: "object", + properties: { + p1: { + enum: [ "v1", "v2"] + }, + p2: { + $ref: "http://myserver/bar-schema.json" + } + } + } + }, { + uri: "http://myserver/bar-schema.json", + schema: { + type: "object", + properties: { + q1: { + enum: [ "x1", "x2"] + } + } + } + }] + }); + } + render() { + const code = this.state.code; + const requireConfig = { + url: 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.1/require.min.js', + paths: { + vs: 'https://as.alipayobjects.com/g/cicada/monaco-editor-mirror/0.6.1/min/vs' + } + }; + return ( +
+ +
+ ); + } +} + +class App extends React.Component { + render() { + return ( +
+

Monaco Editor Sample (controlled mode)

+ +
+

Another editor (uncontrolled mode)

+ +
+ ); + } +} + +render( + , + document.getElementById('root') +); diff --git a/types/react-monaco-editor/tsconfig.json b/types/react-monaco-editor/tsconfig.json new file mode 100644 index 0000000000..0b3178ab81 --- /dev/null +++ b/types/react-monaco-editor/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-monaco-editor-tests.tsx" + ] +} diff --git a/types/react-monaco-editor/tslint.json b/types/react-monaco-editor/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-monaco-editor/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 1d19461b6e52f2b639766f3fbe17cc97faa616ef Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 5 May 2017 16:36:51 -0700 Subject: [PATCH 43/50] Update state type parameter (#16361) --- types/react-router/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index 43fe16f484..d5bc7240c7 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -70,12 +70,12 @@ export interface RouteProps { exact?: boolean; strict?: boolean; } -export class Route extends React.Component { } +export class Route extends React.Component { } export interface RouterProps { history: any; } -export class Router extends React.Component { } +export class Router extends React.Component { } export interface StaticRouterProps { basename?: string; @@ -83,12 +83,12 @@ export interface StaticRouterProps { context?: object; } -export class StaticRouter extends React.Component { } +export class StaticRouter extends React.Component { } export interface SwitchProps { children?: React.ReactNode; location?: H.Location; } -export class Switch extends React.Component { } +export class Switch extends React.Component { } export interface match

{ params: P; From 868b7fa0e1aae75347a1744fc0f5f585da9cf2d5 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 5 May 2017 16:42:32 -0700 Subject: [PATCH 44/50] Fix Ramda for Global 'R' Symbol (#16362) * Fix Ramda for Global 'R' Symbol **bug** The Ramda global `R` symbol is not defined. This means that Ramda must be used as module. This breaks intellisense for some JavaScript project setups in VSCode **fix** Declare a 'ramda' module. This preserves the global `R` symbol * Use export as instead --- types/ramda/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 20ad9529a9..7fde62feee 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1808,3 +1808,4 @@ declare namespace R { } export = R; +export as namespace R; From d0dab167cda6b9c39da7280f8b988d3ad8632b68 Mon Sep 17 00:00:00 2001 From: Michael Zlatkovsky Date: Fri, 5 May 2017 17:51:11 -0700 Subject: [PATCH 45/50] Remove "removeAll" method on event handlers (#16363) The Office.js team (of which I am a member) has decided to remove this method. It will still exist in silent deprecated mode, but we will no longer add new events that have a "removeAll", and we want to strongly discourage this method's existence. Since this was only added very recently, we believe that it's best to just remove it outright, rather than add special notices about its deprecation, etc. The likely number of folks using it today is close to 0. --- types/office-js/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index e6f947b677..520928823e 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -2412,7 +2412,6 @@ declare module OfficeExtension { constructor(context: ClientRequestContext, parentObject: ClientObject, name: string, eventInfo: EventInfo); add(handler: (args: T) => IPromise): EventHandlerResult; remove(handler: (args: T) => IPromise): void; - removeAll(): void; } export class EventHandlerResult { From 0307072de4098aed7508a0efe26fd0dd01e4470c Mon Sep 17 00:00:00 2001 From: David Xiao Date: Sat, 6 May 2017 15:44:55 -0700 Subject: [PATCH 46/50] React-native: export ImageURISource Useful for passing around the struct before giving to to the \ component. --- types/react-native/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 7a02b28e6b..c5a656d15d 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3123,9 +3123,9 @@ export interface ImageStyle extends FlexStyle, TransformsStyle, ShadowStyleIOS { } /* - * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageSourcePropType.js - */ -interface ImageURISource { + * @see https://github.com/facebook/react-native/blob/master/Libraries/Image/ImageSourcePropType.js + */ +export interface ImageURISource { /** * `uri` is a string representing the resource identifier for the image, which * could be an http address, a local file path, or the name of a static image From eab9a9239c736220e6b59136775c82bebf37d9ad Mon Sep 17 00:00:00 2001 From: Jason Healy Date: Tue, 9 May 2017 16:35:13 +0100 Subject: [PATCH 47/50] change snapToInterval prop from array to number --- types/react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index a7dc4da43a..1f407e7f02 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -5769,7 +5769,7 @@ export interface ScrollViewPropertiesIOS { * This can be used for paginating through children that have lengths smaller than the scroll view. * Used in combination with snapToAlignment. */ - snapToInterval?: number[] + snapToInterval?: number /** * An array of child indices determining which children get docked to the From a6e481c4bc9cf11c1dec0d77d0118d9c3430415f Mon Sep 17 00:00:00 2001 From: asakasa Date: Wed, 10 May 2017 02:37:09 +0900 Subject: [PATCH 48/50] Add new types for TabBar in react-native The types are available since iOS 10. And then test for TabBar added. --- types/react-native/index.d.ts | 10 ++++++++++ types/react-native/test/index.tsx | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index c5a656d15d..5b3b1f3a38 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -5097,6 +5097,11 @@ export interface TabBarItemProperties extends ViewProperties { */ badge?: string | number + /** + * Background color for the badge. Available since iOS 10. + */ + badgeColor?: string + /** * A custom icon for the tab. It is ignored when a system icon is defined. */ @@ -5182,6 +5187,11 @@ export interface TabBarIOSProperties extends ViewProperties { * Color of text on unselected tabs */ unselectedTintColor?: string + + /** + * Color of unselected tab icons. Available since iOS 10. + */ + unselectedItemTintColor?: string } export interface TabBarIOSStatic extends React.ComponentClass { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 62e925575b..3d7ddeac07 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -34,6 +34,7 @@ import { ScrollView, ScrollViewProps, RefreshControl, + TabBarIOS, } from 'react-native'; function testDimensions() { @@ -255,3 +256,30 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi ) } } + + +class TabBarTest extends React.Component<{}, {}> { + render() { + return ( + + {}} + renderAsOriginal={ true } + selectedIcon={ undefined } + systemIcon="history" + title="Item 1"> + + + ); + } +} From bf2499f1d28475dd2c8cc62dde44a9e83f0a94c5 Mon Sep 17 00:00:00 2001 From: asakasa Date: Wed, 10 May 2017 03:16:59 +0900 Subject: [PATCH 49/50] Update version of React Native Now current version of React Native is 0.44 --- types/react-native/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 5b3b1f3a38..214352f808 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-native 0.43 +// Type definitions for react-native 0.44 // Project: https://github.com/facebook/react-native // Definitions by: Eloy Durán , Fedor Nezhivoi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From ac9bfc4eecf7a700c8fe0033d4a41f1dd8c2581f Mon Sep 17 00:00:00 2001 From: Klaus Sevensleeper Date: Wed, 10 May 2017 17:14:56 +0200 Subject: [PATCH 50/50] enhance signature of create for conversion from object (#16381) --- types/xmlbuilder/index.d.ts | 2 +- types/xmlbuilder/xmlbuilder-tests.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/xmlbuilder/index.d.ts b/types/xmlbuilder/index.d.ts index 20dabf97ca..d7ffd2193c 100644 --- a/types/xmlbuilder/index.d.ts +++ b/types/xmlbuilder/index.d.ts @@ -85,5 +85,5 @@ declare class XMLElementOrXMLNode { } declare namespace xmlbuilder { - function create(name: string, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; + function create(nameOrObjSpec: string | { [name:string]: Object }, xmldec?: Object, doctype?: any, options?: Object): XMLElementOrXMLNode; } diff --git a/types/xmlbuilder/xmlbuilder-tests.ts b/types/xmlbuilder/xmlbuilder-tests.ts index 69794640ba..8be8f780f9 100644 --- a/types/xmlbuilder/xmlbuilder-tests.ts +++ b/types/xmlbuilder/xmlbuilder-tests.ts @@ -41,3 +41,10 @@ xml('root') .up() .ele('atttest', 'text') .end(); + +xml({ + displayNotification: { + level: 'error', + message: 'an error occurred' + } +}); \ No newline at end of file