From 6bf0d5674fb9cbd32abc36a3d5f6e804dab344ba Mon Sep 17 00:00:00 2001 From: Stefan Dobrev Date: Fri, 21 Oct 2016 15:49:26 +0300 Subject: [PATCH 01/24] [material-ui] ListItem and MenuItem props fixes `MenuItem` properties are passed to the underlying `ListItem` element. Remove the extending of `React.Props<>` because it is causing problems with multiple implementation of the `ref` property with different generic arguments. `React.Props<>` is deprecated nevertheless. The same applies to `ListItem` properties and its underlying `EnhancedButton`. --- material-ui/index.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/material-ui/index.d.ts b/material-ui/index.d.ts index a6ed3cff6b..aee74c1c0c 100644 --- a/material-ui/index.d.ts +++ b/material-ui/index.d.ts @@ -1063,7 +1063,7 @@ declare namespace __MaterialUI { export class List extends React.Component { } - interface ListItemProps extends React.HTMLAttributes<{}>, React.Props { + interface ListItemProps extends EnhancedButtonProps { // is the element that get the 'other' properties autoGenerateNestedIndicator?: boolean; disableKeyboardFocus?: boolean; @@ -1137,7 +1137,7 @@ declare namespace __MaterialUI { export class Menu extends React.Component{ } - interface MenuItemProps extends React.HTMLAttributes<{}>, React.Props { + interface MenuItemProps extends List.ListItemProps { // is the element that get the 'other' properties checked?: boolean; desktop?: boolean; @@ -1152,10 +1152,6 @@ declare namespace __MaterialUI { secondaryText?: React.ReactNode; style?: React.CSSProperties; value?: any; - - // useful attributes passed to - primaryText?: React.ReactNode; - secondaryTextLines?: number; // 1 or 2 } export class MenuItem extends React.Component{ } From a28743f6483ba813d46cc316eac8a21e54e8719f Mon Sep 17 00:00:00 2001 From: Jacek Jagiello Date: Fri, 11 Nov 2016 23:18:40 +0100 Subject: [PATCH 02/24] Added type definitions for react-hot-loader --- react-hot-loader/index.d.ts | 20 ++++++++++++++ react-hot-loader/react-hot-loader-tests.tsx | 29 +++++++++++++++++++++ react-hot-loader/tsconfig.json | 20 ++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 react-hot-loader/index.d.ts create mode 100644 react-hot-loader/react-hot-loader-tests.tsx create mode 100644 react-hot-loader/tsconfig.json diff --git a/react-hot-loader/index.d.ts b/react-hot-loader/index.d.ts new file mode 100644 index 0000000000..aeeb958a93 --- /dev/null +++ b/react-hot-loader/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for react-hot-loader +// Project: https://github.com/gaearon/react-hot-loader +// Definitions by: Jacek Jagiello +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from "react" + +declare module "react-hot-loader" { + + interface ErrorReporterProps { + error: any + } + + export interface AppContainerProps { + children?: React.ReactElement, + errorReporter?: React.StatelessComponent + } + + export class AppContainer extends React.Component {} +} diff --git a/react-hot-loader/react-hot-loader-tests.tsx b/react-hot-loader/react-hot-loader-tests.tsx new file mode 100644 index 0000000000..78da915b20 --- /dev/null +++ b/react-hot-loader/react-hot-loader-tests.tsx @@ -0,0 +1,29 @@ +import * as React from 'react' +import { AppContainer } from 'react-hot-loader' + +interface ErrorReporterProps { + error: any +} + +class ErrorReporterComponent extends React.Component { + public render() { + return

{this.props.error.message}

+ } +} + +const DummyComponent = () =>

Dummy component

+const ErrorReporter = ({ error } : ErrorReporterProps) => + +class AppContainerTest extends React.Component { + public render() { + return ( +
+ + + +
+ ) + } +} + +export default AppContainerTest diff --git a/react-hot-loader/tsconfig.json b/react-hot-loader/tsconfig.json new file mode 100644 index 0000000000..a25cbaa2ed --- /dev/null +++ b/react-hot-loader/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-hot-loader-tests.tsx" + ] +} From 2bfcbef012ea400f1973254b872c99ced87b0600 Mon Sep 17 00:00:00 2001 From: Jacek Jagiello Date: Sat, 12 Nov 2016 10:40:45 +0100 Subject: [PATCH 03/24] react-hot-loader - Added library version number, make errorReporter compatible with non-stateless React components --- react-hot-loader/index.d.ts | 4 ++-- react-hot-loader/react-hot-loader-tests.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-hot-loader/index.d.ts b/react-hot-loader/index.d.ts index aeeb958a93..202566a5b4 100644 --- a/react-hot-loader/index.d.ts +++ b/react-hot-loader/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-hot-loader +// Type definitions for react-hot-loader 3.0.0-beta.6 // Project: https://github.com/gaearon/react-hot-loader // Definitions by: Jacek Jagiello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13,7 +13,7 @@ declare module "react-hot-loader" { export interface AppContainerProps { children?: React.ReactElement, - errorReporter?: React.StatelessComponent + errorReporter?: React.ComponentClass | React.StatelessComponent } export class AppContainer extends React.Component {} diff --git a/react-hot-loader/react-hot-loader-tests.tsx b/react-hot-loader/react-hot-loader-tests.tsx index 78da915b20..08866fcbb9 100644 --- a/react-hot-loader/react-hot-loader-tests.tsx +++ b/react-hot-loader/react-hot-loader-tests.tsx @@ -18,7 +18,7 @@ class AppContainerTest extends React.Component { public render() { return (
- +
From 9eb29720d106a3c317e892bbd82c4347098d4b52 Mon Sep 17 00:00:00 2001 From: Todd Dukart Date: Sun, 2 Oct 2016 21:01:30 -0400 Subject: [PATCH 04/24] Update Howler to 2.0.0 --- howler/howler-tests.ts | 45 ++++++++++++++----- howler/index.d.ts | 100 ++++++++++++++++++++--------------------- 2 files changed, 82 insertions(+), 63 deletions(-) diff --git a/howler/howler-tests.ts b/howler/howler-tests.ts index bdd3a575bd..accfbe9398 100644 --- a/howler/howler-tests.ts +++ b/howler/howler-tests.ts @@ -1,19 +1,15 @@ -/** - * howler-tests.ts - * Created by xperiments on 02/09/14. - */ +/// import * as howler from "howler"; -Howler.codecs('ogg'); -Howler.iOSAutoEnable = true; var sound = new Howl({ - urls: ['sound.mp3'] -}).play(); + src: ['sound.mp3'] +}); +sound.play(); var sound = new Howl({ - urls: ['sound.mp3', 'sound.ogg', 'sound.wav'], + src: ['sound.webm', 'sound.mp3', 'sound.wav'], autoplay: true, loop: true, volume: 0.5, @@ -23,7 +19,7 @@ var sound = new Howl({ }); var sound = new Howl({ - urls: ['sounds.mp3', 'sounds.ogg'], + src: ['sounds.webm', 'sounds.mp3'], sprite: { blast: [0, 1000], laser: [2000, 3000], @@ -31,5 +27,32 @@ var sound = new Howl({ } }); -// shoot the laser! +// Shoot the laser! sound.play('laser'); + +var sound = new Howl({ + src: ['sound.webm', 'sound.mp3'] +}); + +// Clear listener after first call. +sound.once('load', function(){ + sound.play(); +}); + +// Fires when the sound finishes playing. +sound.on('end', function(){ + console.log('Finished!'); +}); + +var sound = new Howl({ + src: ['sound.webm', 'sound.mp3'] +}); + +// Play returns a uniqe Sound ID that can be passed +// into any method on Howl to control that specific sound. +var id1 = sound.play(); +var id2 = sound.play(); + +// Fade out the first sound and speed up the second. +sound.fade(1, 0, 1000, id1); +sound.rate(1.5, id2); diff --git a/howler/index.d.ts b/howler/index.d.ts index cdb95ce44f..71115b1d42 100644 --- a/howler/index.d.ts +++ b/howler/index.d.ts @@ -1,73 +1,69 @@ -// Type definitions for howler.js v1.1.29 +// Type definitions for howler.js v2.0.0 // Project: https://github.com/goldfire/howler.js -// Definitions by: Pedro Casaubon +// Definitions by: Pedro Casaubon , Todd Dukart // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare class HowlerGlobal { - mute(muted: boolean): HowlerGlobal; - volume(): number; - volume(volume: number): HowlerGlobal; - codecs(extension: string): boolean; - iOSAutoEnable: boolean; +interface HowlerGlobal { + mute(muted: boolean): void; + volume(volume?: number): number; + codecs(ext: string): boolean; + unload(): void; + usingWebAudio: boolean; + noAudio: boolean; + mobileAudioEnable: boolean; + autoSuspend: boolean; + ctx: boolean; + masterGain: boolean; } -declare var Howler: HowlerGlobal; +declare let Howler: HowlerGlobal; interface IHowlSoundSpriteDefinition { - [name: string]: number[]; + [name: string]: [number, number]|[number, number, boolean] } -declare type HowlPos3d = [number, number, number]|[number, number, number, number]; - interface IHowlProperties { - autoplay?: boolean; - buffer?: boolean; - duration?: number; - format?: string; - loop?: boolean; - sprite?: IHowlSoundSpriteDefinition; - src?: string; - pos3d?: HowlPos3d; + src: string|string[]; volume?: number; - urls?: string[]; + html5?: boolean; + loop?: boolean; + preload?: boolean; + autoplay?: boolean; + mute?: boolean; + sprite?: IHowlSoundSpriteDefinition; rate?: number; - model?: 'equalpower'|'HRTF'; - onend?: Function; + pool?: number; + format?: string[]; onload?: Function; onloaderror?: Function; - onpause?: Function; onplay?: Function; + onend?: Function; + onpause?: Function; + onstop?: Function; + onmute?: Function; + onvolume?: Function; + onrate?: Function; + onseek?: Function; + onfade?: Function; } interface Howl { - autoplay: Boolean; - buffer: Boolean; - format: string; - rate: number; - model: string; - onend: Function; - onload: Function; - onloaderror: Function; - onpause: Function; - onplay: Function; - load(): Howl; - play(sprite?: string, callback?: (soundId: string) => void): Howl; - play(callback?: (soundId: string) => void): Howl; - pause(soundId?: string): Howl; - stop(soundId?: string): Howl; - mute(muted?: boolean, soundId?: string): Howl; - fade(from: number, to: number, duration: number, callback?: Function, soundId?: string): Howl; - loop(): boolean; - loop(loop: boolean): Howl; - pos(position?: number, soundId?: string): number; - pos3d(x: number, y: number, z: number, soundId?: string): any; - sprite(definition?: IHowlSoundSpriteDefinition): IHowlSoundSpriteDefinition; - volume(): number; - volume(volume?: number, soundId?: string): Howl; - urls(): string[]; - urls(urls: string[]): Howl; - on(event: string, listener?: Function): Howl; - off(event: string, listener?: Function): Howl; + play(spriteOrId?: string|number): number; // .play() is not chainable; the other methods are + pause(id?: number): Howl; + stop(id?: number): Howl; + mute(muted?: boolean, id?: number): Howl; + volume(volume?: number, id?: number): Howl; + fade(from: number, to: number, duration: number, id?: number): Howl; + rate(rate?: number, id?: number): Howl; + seek(seek?: number, id?: number): Howl; + loop(loop?: boolean, id?: number): Howl; + state(): string; + playing(id?: number): boolean; + duration(id?: number): number; + on(event: string, callback: Function, id?: number): Howl; + once(event: string, callback: Function, id?: number): Howl; + off(event: string, callback?: Function, id?: number): Howl; + load(): void; unload(): void; } From c612dcef6cc52ec00cdad4d6a75f7d228efc7fc4 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 14 Nov 2016 14:08:37 -0800 Subject: [PATCH 05/24] Correct Howler 2 typings --- howler/howler-tests.ts | 2 - howler/index.d.ts | 92 +++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 29 deletions(-) diff --git a/howler/howler-tests.ts b/howler/howler-tests.ts index accfbe9398..7b47b73abb 100644 --- a/howler/howler-tests.ts +++ b/howler/howler-tests.ts @@ -1,5 +1,3 @@ -/// - import * as howler from "howler"; var sound = new Howl({ diff --git a/howler/index.d.ts b/howler/index.d.ts index 71115b1d42..1b6604b1aa 100644 --- a/howler/index.d.ts +++ b/howler/index.d.ts @@ -5,15 +5,16 @@ interface HowlerGlobal { mute(muted: boolean): void; - volume(volume?: number): number; + volume(): number; + volume(volume: number): this; codecs(ext: string): boolean; unload(): void; usingWebAudio: boolean; noAudio: boolean; mobileAudioEnable: boolean; autoSuspend: boolean; - ctx: boolean; - masterGain: boolean; + ctx: AudioContext; + masterGain: GainNode; } declare let Howler: HowlerGlobal; @@ -33,36 +34,73 @@ interface IHowlProperties { sprite?: IHowlSoundSpriteDefinition; rate?: number; pool?: number; - format?: string[]; - onload?: Function; - onloaderror?: Function; - onplay?: Function; - onend?: Function; - onpause?: Function; - onstop?: Function; - onmute?: Function; - onvolume?: Function; - onrate?: Function; - onseek?: Function; - onfade?: Function; + format?: string[] | string; + onload?: () => void; + onloaderror?: (soundId: number, error: any) => void; + onplay?: (soundId: number) => void; + onend?: (soundId: number) => void; + onpause?: (soundId: number) => void; + onstop?: (soundId: number) => void; + onmute?: (soundId: number) => void; + onvolume?: (soundId: number) => void; + onrate?: (soundId: number) => void; + onseek?: (soundId: number) => void; + onfade?: (soundId: number) => void; } interface Howl { play(spriteOrId?: string|number): number; // .play() is not chainable; the other methods are - pause(id?: number): Howl; - stop(id?: number): Howl; - mute(muted?: boolean, id?: number): Howl; - volume(volume?: number, id?: number): Howl; - fade(from: number, to: number, duration: number, id?: number): Howl; - rate(rate?: number, id?: number): Howl; - seek(seek?: number, id?: number): Howl; - loop(loop?: boolean, id?: number): Howl; - state(): string; + pause(id?: number): this; + stop(id?: number): this; + + mute(): boolean; + mute(muted: boolean, id?: number): this; + + volume(): number; + volume(idOrSetVolume: number): this | number; + volume(volume: number, id: number): this; + + fade(from: number, to: number, duration: number, id?: number): this; + + rate(): number; + rate(idOrSetRate: number): this | number; + rate(rate: number, id: number): this; + + seek(seek?: number, id?: number): this; + loop(loop?: boolean, id?: number): this; playing(id?: number): boolean; duration(id?: number): number; - on(event: string, callback: Function, id?: number): Howl; - once(event: string, callback: Function, id?: number): Howl; - off(event: string, callback?: Function, id?: number): Howl; + + + on(event: 'load', callback: () => void, id?: number): this; + on(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this; + on(event: 'play', callback: (soundId: number) => void, id?: number): this; + on(event: 'end', callback: (soundId: number) => void, id?: number): this; + on(event: 'pause', callback: (soundId: number) => void, id?: number): this; + on(event: 'stop', callback: (soundId: number) => void, id?: number): this; + on(event: 'mute', callback: (soundId: number) => void, id?: number): this; + on(event: 'volume', callback: (soundId: number) => void, id?: number): this; + on(event: 'rate', callback: (soundId: number) => void, id?: number): this; + on(event: 'seek', callback: (soundId: number) => void, id?: number): this; + on(event: 'fade', callback: (soundId: number) => void, id?: number): this; + on(event: string, callback: Function, id?: number): this; + + once(event: 'load', callback: () => void, id?: number): this; + once(event: 'loaderror', callback: (soundId: number, error: any) => void, id?: number): this; + once(event: 'play', callback: (soundId: number) => void, id?: number): this; + once(event: 'end', callback: (soundId: number) => void, id?: number): this; + once(event: 'pause', callback: (soundId: number) => void, id?: number): this; + once(event: 'stop', callback: (soundId: number) => void, id?: number): this; + once(event: 'mute', callback: (soundId: number) => void, id?: number): this; + once(event: 'volume', callback: (soundId: number) => void, id?: number): this; + once(event: 'rate', callback: (soundId: number) => void, id?: number): this; + once(event: 'seek', callback: (soundId: number) => void, id?: number): this; + once(event: 'fade', callback: (soundId: number) => void, id?: number): this; + once(event: string, callback: Function, id?: number): this; + + off(event: string, callback?: Function, id?: number): this; + + state(): 'unloaded' | 'loading' | 'loaded'; load(): void; unload(): void; } From b8fb1fb2f1b794964dc8a40e3e50b18720bf0d70 Mon Sep 17 00:00:00 2001 From: heycalmdown Date: Mon, 14 Nov 2016 11:24:49 +0900 Subject: [PATCH 06/24] Add an initial definition for --- msgpack5/index.d.ts | 52 +++++++++++++++++++++++++++++++++++++++ msgpack5/msgpack5-test.ts | 6 +++++ msgpack5/tsconfig.json | 20 +++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 msgpack5/index.d.ts create mode 100644 msgpack5/msgpack5-test.ts create mode 100644 msgpack5/tsconfig.json diff --git a/msgpack5/index.d.ts b/msgpack5/index.d.ts new file mode 100644 index 0000000000..361f817514 --- /dev/null +++ b/msgpack5/index.d.ts @@ -0,0 +1,52 @@ +// Type definitions for msgpack5 v3.4.0 +// Project: https://github.com/mcollina/msgpack5/ +// Definitions by: Wonshik Kim +// Definitions by: Kei Son +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import stream = require('stream'); +import bl = require('bl'); + +interface Options { + forceFloat64: boolean; + compatibilityMode: boolean; +} + +declare namespace msgpack5 { + interface Options { + header?: boolean; + msgpack?: any; + } + + class Base extends stream.Transform { + protected _header: any; + protected _msgpack: any; + } + + class Encoder extends Base { + constructor(opts?: Options); + public _transform(obj: any, enc: any, done: Function): any; + } + + class Decoder extends Base { + constructor(opts?: Options); + public _chunks: bl; + public _length: number; + public _transform(buf: any, enc: any, done: Function): any; + } + + interface MessagePack { + encode(obj: any): bl; + decode(buf: Buffer): T; + decode(buf: bl): T; + register(type: number, $constructor: any, encode: (obj: any) => Buffer, decode: (data: Buffer) => any): any; + registerEncoder(check: (obj: any) => boolean, encode: (obj: any) => Buffer): any; + registerDecoder(type: number, decode: (data: Buffer) => any): any; + encoder(opts?: Options): Encoder; + decoder(opts?: Options): Decoder; + } +} + +declare function msgpack5(opts?: Options): msgpack5.MessagePack; + +export = msgpack5; diff --git a/msgpack5/msgpack5-test.ts b/msgpack5/msgpack5-test.ts new file mode 100644 index 0000000000..ad2d86d9a6 --- /dev/null +++ b/msgpack5/msgpack5-test.ts @@ -0,0 +1,6 @@ +import * as msgpack5 from 'msgpack5'; + +const packer = msgpack5(); +const IN = {}; +const OUT = packer.decode(packer.encode(IN)); + diff --git a/msgpack5/tsconfig.json b/msgpack5/tsconfig.json new file mode 100644 index 0000000000..5a4cfa1259 --- /dev/null +++ b/msgpack5/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "msgpack5-test.ts" + ] +} From ab5c71adc84487f1920fe8f76410b69d89d35f40 Mon Sep 17 00:00:00 2001 From: heycalmdown Date: Tue, 15 Nov 2016 13:37:55 +0900 Subject: [PATCH 07/24] Adopt a review by @andy-ms - Combine authors on a line - turn the `strictNullChecks` on --- msgpack5/index.d.ts | 3 +-- msgpack5/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/msgpack5/index.d.ts b/msgpack5/index.d.ts index 361f817514..ceb02cc758 100644 --- a/msgpack5/index.d.ts +++ b/msgpack5/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for msgpack5 v3.4.0 // Project: https://github.com/mcollina/msgpack5/ -// Definitions by: Wonshik Kim -// Definitions by: Kei Son +// Definitions by: Wonshik Kim , Kei Son // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import stream = require('stream'); diff --git a/msgpack5/tsconfig.json b/msgpack5/tsconfig.json index 5a4cfa1259..82e4af0f63 100644 --- a/msgpack5/tsconfig.json +++ b/msgpack5/tsconfig.json @@ -4,7 +4,7 @@ "moduleResolution": "node", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" From 11791dc92d243b86a6868fecc6f0fe6d2275c048 Mon Sep 17 00:00:00 2001 From: "ali.ibrahim" Date: Thu, 10 Nov 2016 13:51:16 +0100 Subject: [PATCH 08/24] Adding TypeScript declarations for Electron net module. --- electron/index.d.ts | 230 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 228 insertions(+), 2 deletions(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index c0797775a2..e9046522d7 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Electron v1.4.2 +// Type definitions for Electron v1.4.5 // Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd , Milan Burda +// Definitions by: jedmao , rhysd , Milan Burda , aliib // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -2687,6 +2687,231 @@ declare namespace Electron { isTemplateImage(): boolean; } + // https://github.com/electron/electron/blob/master/docs/api/net.md + + /** + * The net module is a client-side API for issuing HTTP(S) requests. + * It is similar to the HTTP and HTTPS modules of Node.js but uses Chromium’s native networking library instead of the Node.js + * implementation, offering better support for web proxies. + * The following is a non-exhaustive list of why you may consider using the net module instead of the native Node.js modules: + * - Automatic management of system proxy configuration, support of the wpad protocol and proxy pac configuration files. + * - Automatic tunneling of HTTPS requests. + * - Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate authentication schemes. + * - Support for traffic monitoring proxies: Fiddler-like proxies used for access control and monitoring. + * + * The net module API has been specifically designed to mimic, as closely as possible, + * the familiar Node.js API. The API components including classes, methods, + * properties and event names are similar to those commonly used in Node.js. + * + * The net API can be used only after the application emits the ready event. + * Trying to use the module before the ready event will throw an error. + */ + interface Net extends NodeJS.EventEmitter { + /** + * @param options The ClientRequest constructor options. + * @param callback A one time listener for the response event. + * + * @returns a ClientRequest instance using the provided options which are directly forwarded to the ClientRequest constructor. + */ + request(options : string | RequestOptions, callback?: (response: IncomingMessage) => void): ClientRequest + } + + /** + * Holds options for an HTTP requests. + */ + interface RequestOptions { + /** + * The HTTP request method. Defaults to the GET method. + */ + method?: string; + /** + * The request URL. Must be provided in the absolute form with the protocol + * scheme specified as http or https. + */ + url?: string; + /** + * The Session instance with which the request is associated. + */ + session?: Session; + /** + * The name of the partition with which the request is associated. + * Defaults to the empty string. The session option prevails on partition. + * Thus if a session is explicitly specified, partition is ignored. + */ + partition?: string; + /** + * The protocol scheme in the form ‘scheme:’. Currently supported values are ‘http:’ or ‘https:’. + * Defaults to ‘http:’. + */ + Protocol?: 'http:' | 'https:'; + /** + * The server host provided as a concatenation of the hostname and the port number ‘hostname:port’. + */ + host?: string; + /** + * The server host name. + */ + hostname?: string; + /** + * The server’s listening port number. + */ + port?: number; + /** + * The path part of the request URL. + */ + path?: string; + /** + * A map specifying extra HTTP header name/value. + */ + headers?: { [key: string]: any }; + } + + /** + * A ClientRequest object represents an HTTP request. + */ + class ClientRequest extends NodeJS.EventEmitter { + /** + * Emitted when a HTTP response is received for the request. + */ + on(event: 'response', listener: (response: IncomingMessage) => void): this; + /** + * Emitted when an authenticating proxy is asking for user credentials. + * The callback function is expected to be called back with user credentials. + * Providing empty credentials will cancel the request and report an authentication error on the response object. + */ + on(event: 'login', listener: (authInfo: LoginAuthInfo, callback: (username?: string, password?: string) => void) => void): this; + /** + * Emitted just after the last chunk of the request’s data has been written into the request object. + */ + on(event: 'finish', listener: () => void): this; + /** + * Emitted when the request is aborted. The abort event will not be fired if the request is already closed. + */ + on(event: 'abort', listener: () => void): this; + /** + * Emitted when the net module fails to issue a network request. + * Typically when the request object emits an error event, a close event will subsequently follow and no response object will be provided. + */ + on(event: 'error', listener: (error: Error) => void): this; + /** + * Emitted as the last event in the HTTP request-response transaction. + * The close event indicates that no more events will be emitted on either the request or response objects. + */ + on(event: 'close', listener: () => void): this; + on(event: string, listener: Function): this; + /** + * A Boolean specifying whether the request will use HTTP chunked transfer encoding or not. + * Defaults to false. The property is readable and writable, however it can be set only before + * the first write operation as the HTTP headers are not yet put on the wire. + * Trying to set the chunkedEncoding property after the first write will throw an error. + * + * Using chunked encoding is strongly recommended if you need to send a large request + * body as data will be streamed in small chunks instead of being internally buffered inside Electron process memory. + */ + chunkedEncoding: boolean; + /** + * @param options If options is a String, it is interpreted as the request URL. + * If it is an object, it is expected to be a RequestOptions. + * @param callback A one time listener for the response event. + */ + constructor(options: string | RequestOptions, callback?: (response: IncomingMessage) => void); + /** + * Adds an extra HTTP header. The header name will issued as it is without lowercasing. + * It can be called only before first write. Calling this method after the first write will throw an error. + * @param name An extra HTTP header name. + * @param value An extra HTTP header value. + */ + setHeader(name: string, value: string): void; + /** + * @param name Specify an extra header name. + * @returns The value of a previously set extra header name. + */ + getHeader(name: string): string; + /** + * Removes a previously set extra header name. This method can be called only before first write. + * Trying to call it after the first write will throw an error. + * @param name Specify an extra header name. + */ + removeHeader(name: string): void; + /** + * Adds a chunk of data to the request body. The first write operation may cause the request headers to be issued on the wire. + * After the first write operation, it is not allowed to add or remove a custom header. + * @param chunk A chunk of the request body’s data. If it is a string, it is converted into a Buffer using the specified encoding. + * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’. + * @param callback Called after the write operation ends. + * + */ + write(chunk: string | Buffer, encoding?: string, callback?: Function): boolean; + /** + * Sends the last chunk of the request data. Subsequent write or end operations will not be allowed. + * The finish event is emitted just after the end operation. + * @param chunk A chunk of the request body’s data. If it is a string, it is converted into a Buffer using the specified encoding. + * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’. + * @param callback Called after the write operation ends. + * + */ + end(chunk?: string | Buffer, encoding?: string, callback?: Function): boolean; + /** + * Cancels an ongoing HTTP transaction. If the request has already emitted the close event, the abort operation will have no effect. + * Otherwise an ongoing event will emit abort and close events. + * Additionally, if there is an ongoing response object,it will emit the aborted event. + */ + abort(): void + } + + /** + * An IncomingMessage represents an HTTP response. + */ + interface IncomingMessage extends NodeJS.ReadableStream { + /** + * The data event is the usual method of transferring response data into applicative code. + */ + on(event: 'data', listener: (chunk: Buffer) => void): this; + /** + * Indicates that response body has ended. + */ + on(event: 'end', listener: () => void): this; + /** + * Emitted when a request has been canceled during an ongoing HTTP transaction. + */ + on(event: 'aborted', listener: () => void): this; + /** + * Emitted when an error was encountered while streaming response data events. + * For instance, if the server closes the underlying while the response is still + * streaming, an error event will be emitted on the response object and a close + * event will subsequently follow on the request object. + */ + on(event: 'error', listener: (error: Error) => void): this; + on(event: string, listener: Function): this; + /** + * An Integer indicating the HTTP response status code. + */ + statusCode: number; + /** + * A String representing the HTTP status message. + */ + statusMessage: string; + /** + * An Object representing the response HTTP headers. The headers object is formatted as follows: + * - All header names are lowercased. + * - Each header name produces an array-valued property on the headers object. + * - Each header value is pushed into the array associated with its header name. + */ + headers: Headers; + /** + * A String indicating the HTTP protocol version number. Typical values are ‘1.0’ or ‘1.1’. + */ + httpVersion: number; + /** + * An integer-valued read-only property that returns the HTTP major version number. + */ + httpVersionMajor: number; + /** + * An integer-valued read-only property that returns the HTTP minor version number. + */ + httpVersionMinor: number; + } + // https://github.com/electron/electron/blob/master/docs/api/power-monitor.md /** @@ -5565,6 +5790,7 @@ declare namespace Electron { globalShortcut: Electron.GlobalShortcut; Menu: typeof Electron.Menu; MenuItem: typeof Electron.MenuItem; + net: Electron.Net; powerMonitor: Electron.PowerMonitor; powerSaveBlocker: Electron.PowerSaveBlocker; protocol: Electron.Protocol; From 87b655f97b95ae76b7741791910e51f75e317902 Mon Sep 17 00:00:00 2001 From: "ali.ibrahim" Date: Thu, 10 Nov 2016 14:17:23 +0100 Subject: [PATCH 09/24] Adding a test case for the net module. --- electron/github-electron-main-tests.ts | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/electron/github-electron-main-tests.ts b/electron/github-electron-main-tests.ts index df5e6723eb..f333e86ec7 100644 --- a/electron/github-electron-main-tests.ts +++ b/electron/github-electron-main-tests.ts @@ -9,6 +9,7 @@ import { ipcMain, Menu, MenuItem, + net, powerMonitor, powerSaveBlocker, protocol, @@ -732,6 +733,51 @@ Menu.buildFromTemplate([ { label: '3', position: 'endof=numbers' } ]); +// net +// https://github.com/electron/electron/blob/master/docs/api/net.md + +app.on('ready', () => { + const request = net.request('https://github.com') + request.setHeader('Some-Custom-Header-Name', 'Some-Custom-Header-Value'); + let header = request.getHeader('Some-Custom-Header-Name'); + request.removeHeader('Some-Custom-Header-Name'); + request.on('response', (response) => { + console.log(`Status code: ${response.statusCode}`); + console.log(`Status message: ${response.statusMessage}`); + console.log(`Headers: ${JSON.stringify(response.headers)}`); + console.log(`Http version: ${response.httpVersion}`); + console.log(`Major Http version: ${response.httpVersionMajor}`); + console.log(`Minor Http version: ${response.httpVersionMinor}`); + response.on('data', (chunk) => { + console.log(`BODY: ${chunk}`); + }) + response.on('end', () => { + console.log('No more data in response.'); + }) + response.on('error', () => { + console.log('"error" event emitted'); + }); + response.on('aborted', () => { + console.log('"aborted" event emitted'); + }); + }) + request.on('login', (authInfo, callback) => { + callback('username', 'password'); + }); + request.on('finish', () => { + console.log('"finish" event emitted'); + }); + request.on('abort', () => { + console.log('"abort" event emitted'); + }); + request.on('error', () => { + console.log('"error" event emitted'); + }); + request.write('Hello World!', 'utf-8', () => { }); + request.end('Hello World!', 'utf-8', () => { }); + request.abort(); +}) + // power-monitor // https://github.com/atom/electron/blob/master/docs/api/power-monitor.md From 01275552b97686edc0a66194cdd9535e8858eeda Mon Sep 17 00:00:00 2001 From: "ali.ibrahim" Date: Thu, 10 Nov 2016 14:29:16 +0100 Subject: [PATCH 10/24] Formatting net module declarations. --- electron/index.d.ts | 66 ++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index e9046522d7..5561af3d27 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2691,13 +2691,18 @@ declare namespace Electron { /** * The net module is a client-side API for issuing HTTP(S) requests. - * It is similar to the HTTP and HTTPS modules of Node.js but uses Chromium’s native networking library instead of the Node.js - * implementation, offering better support for web proxies. - * The following is a non-exhaustive list of why you may consider using the net module instead of the native Node.js modules: - * - Automatic management of system proxy configuration, support of the wpad protocol and proxy pac configuration files. + * It is similar to the HTTP and HTTPS modules of Node.js but uses Chromium’s native + * networking library instead of the Node.js implementation, offering better support + * for web proxies. + * The following is a non-exhaustive list of why you may consider using the net module + * instead of the native Node.js modules: + * - Automatic management of system proxy configuration, support of the wpad protocol + * and proxy pac configuration files. * - Automatic tunneling of HTTPS requests. - * - Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate authentication schemes. - * - Support for traffic monitoring proxies: Fiddler-like proxies used for access control and monitoring. + * - Support for authenticating proxies using basic, digest, NTLM, Kerberos or negotiate + * authentication schemes. + * - Support for traffic monitoring proxies: Fiddler-like proxies used for access control + * and monitoring. * * The net module API has been specifically designed to mimic, as closely as possible, * the familiar Node.js API. The API components including classes, methods, @@ -2711,13 +2716,14 @@ declare namespace Electron { * @param options The ClientRequest constructor options. * @param callback A one time listener for the response event. * - * @returns a ClientRequest instance using the provided options which are directly forwarded to the ClientRequest constructor. + * @returns a ClientRequest instance using the provided options which are directly + * forwarded to the ClientRequest constructor. */ request(options : string | RequestOptions, callback?: (response: IncomingMessage) => void): ClientRequest } /** - * Holds options for an HTTP requests. + * The RequestOptions interface allows to define various options for an HTTP request. */ interface RequestOptions { /** @@ -2767,35 +2773,40 @@ declare namespace Electron { } /** - * A ClientRequest object represents an HTTP request. + * The ClientRequest class represents an HTTP request. */ class ClientRequest extends NodeJS.EventEmitter { /** - * Emitted when a HTTP response is received for the request. + * Emitted when an HTTP response is received for the request. */ on(event: 'response', listener: (response: IncomingMessage) => void): this; /** * Emitted when an authenticating proxy is asking for user credentials. * The callback function is expected to be called back with user credentials. - * Providing empty credentials will cancel the request and report an authentication error on the response object. + * Providing empty credentials will cancel the request and report an authentication + * error on the response object. */ on(event: 'login', listener: (authInfo: LoginAuthInfo, callback: (username?: string, password?: string) => void) => void): this; /** - * Emitted just after the last chunk of the request’s data has been written into the request object. + * Emitted just after the last chunk of the request’s data has been written into + * the request object. */ on(event: 'finish', listener: () => void): this; /** - * Emitted when the request is aborted. The abort event will not be fired if the request is already closed. + * Emitted when the request is aborted. The abort event will not be fired if the + * request is already closed. */ on(event: 'abort', listener: () => void): this; /** * Emitted when the net module fails to issue a network request. - * Typically when the request object emits an error event, a close event will subsequently follow and no response object will be provided. + * Typically when the request object emits an error event, a close event will + * subsequently follow and no response object will be provided. */ on(event: 'error', listener: (error: Error) => void): this; /** * Emitted as the last event in the HTTP request-response transaction. - * The close event indicates that no more events will be emitted on either the request or response objects. + * The close event indicates that no more events will be emitted on either the + * request or response objects. */ on(event: 'close', listener: () => void): this; on(event: string, listener: Function): this; @@ -2806,7 +2817,8 @@ declare namespace Electron { * Trying to set the chunkedEncoding property after the first write will throw an error. * * Using chunked encoding is strongly recommended if you need to send a large request - * body as data will be streamed in small chunks instead of being internally buffered inside Electron process memory. + * body as data will be streamed in small chunks instead of being internally buffered + * inside Electron process memory. */ chunkedEncoding: boolean; /** @@ -2817,7 +2829,8 @@ declare namespace Electron { constructor(options: string | RequestOptions, callback?: (response: IncomingMessage) => void); /** * Adds an extra HTTP header. The header name will issued as it is without lowercasing. - * It can be called only before first write. Calling this method after the first write will throw an error. + * It can be called only before first write. Calling this method after the first write + * will throw an error. * @param name An extra HTTP header name. * @param value An extra HTTP header value. */ @@ -2834,25 +2847,28 @@ declare namespace Electron { */ removeHeader(name: string): void; /** - * Adds a chunk of data to the request body. The first write operation may cause the request headers to be issued on the wire. + * Adds a chunk of data to the request body. The first write operation may cause the + * request headers to be issued on the wire. * After the first write operation, it is not allowed to add or remove a custom header. - * @param chunk A chunk of the request body’s data. If it is a string, it is converted into a Buffer using the specified encoding. + * @param chunk A chunk of the request body’s data. If it is a string, it is converted + * into a Buffer using the specified encoding. * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’. * @param callback Called after the write operation ends. - * */ write(chunk: string | Buffer, encoding?: string, callback?: Function): boolean; /** * Sends the last chunk of the request data. Subsequent write or end operations will not be allowed. * The finish event is emitted just after the end operation. - * @param chunk A chunk of the request body’s data. If it is a string, it is converted into a Buffer using the specified encoding. + * @param chunk A chunk of the request body’s data. If it is a string, it is converted into + * a Buffer using the specified encoding. * @param encoding Used to convert string chunks into Buffer objects. Defaults to ‘utf-8’. * @param callback Called after the write operation ends. * */ end(chunk?: string | Buffer, encoding?: string, callback?: Function): boolean; /** - * Cancels an ongoing HTTP transaction. If the request has already emitted the close event, the abort operation will have no effect. + * Cancels an ongoing HTTP transaction. If the request has already emitted the close event, + * the abort operation will have no effect. * Otherwise an ongoing event will emit abort and close events. * Additionally, if there is an ongoing response object,it will emit the aborted event. */ @@ -2892,16 +2908,16 @@ declare namespace Electron { */ statusMessage: string; /** - * An Object representing the response HTTP headers. The headers object is formatted as follows: + * An object representing the response HTTP headers. The headers object is formatted as follows: * - All header names are lowercased. * - Each header name produces an array-valued property on the headers object. * - Each header value is pushed into the array associated with its header name. */ headers: Headers; /** - * A String indicating the HTTP protocol version number. Typical values are ‘1.0’ or ‘1.1’. + * A string indicating the HTTP protocol version number. Typical values are ‘1.0’ or ‘1.1’. */ - httpVersion: number; + httpVersion: ; /** * An integer-valued read-only property that returns the HTTP major version number. */ From f01b6061b0483ab5c4b96f590ce617a14ad6f4b3 Mon Sep 17 00:00:00 2001 From: "ali.ibrahim" Date: Mon, 14 Nov 2016 10:28:30 +0100 Subject: [PATCH 11/24] Fixing a missing type. --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 5561af3d27..5fe413e144 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2917,7 +2917,7 @@ declare namespace Electron { /** * A string indicating the HTTP protocol version number. Typical values are ‘1.0’ or ‘1.1’. */ - httpVersion: ; + httpVersion: string; /** * An integer-valued read-only property that returns the HTTP major version number. */ From c5bef6a3c4f7f34c5208fba1a1d83efe4d71726d Mon Sep 17 00:00:00 2001 From: "ali.ibrahim" Date: Tue, 15 Nov 2016 09:57:06 +0100 Subject: [PATCH 12/24] [SAP-150] Fixing come code review issues. --- electron/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 5fe413e144..d55b47df4c 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2719,7 +2719,7 @@ declare namespace Electron { * @returns a ClientRequest instance using the provided options which are directly * forwarded to the ClientRequest constructor. */ - request(options : string | RequestOptions, callback?: (response: IncomingMessage) => void): ClientRequest + request(options: string | RequestOptions, callback?: (response: IncomingMessage) => void): ClientRequest; } /** @@ -5806,7 +5806,7 @@ declare namespace Electron { globalShortcut: Electron.GlobalShortcut; Menu: typeof Electron.Menu; MenuItem: typeof Electron.MenuItem; - net: Electron.Net; + net: Electron.Net; powerMonitor: Electron.PowerMonitor; powerSaveBlocker: Electron.PowerSaveBlocker; protocol: Electron.Protocol; From 2418ac66fc9cb3f098cad1363fd42f585f74c2d8 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 15 Nov 2016 06:43:09 -0800 Subject: [PATCH 13/24] Use only 1 process for running tests (stop travis from crashing) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9162cf748..49e9d27d51 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "node": ">= 6.9.1" }, "scripts": { - "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed" + "test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed --nProcesses 1" }, "devDependencies": { "types-publisher": "Microsoft/types-publisher#production" From 839078e2402f80431417a00128b4a82f762b8c01 Mon Sep 17 00:00:00 2001 From: Cyril Schumacher Date: Tue, 15 Nov 2016 20:06:04 +0100 Subject: [PATCH 14/24] Add definition for "neo4j" (#12640) * Add definition for "neo4j". * Fix reference in test file. * Remove unnecessary "neo4j" namespace. * Remove unnecessary comments, module and type declaration. Rename "neo4j-2.0.0-tests.ts" to "neo4j-tests.ts". --- neo4j/index.d.ts | 278 +++++++++++++++++++++++++++++++++++++++++++ neo4j/neo4j-tests.ts | 55 +++++++++ neo4j/tsconfig.json | 19 +++ 3 files changed, 352 insertions(+) create mode 100644 neo4j/index.d.ts create mode 100644 neo4j/neo4j-tests.ts create mode 100644 neo4j/tsconfig.json diff --git a/neo4j/index.d.ts b/neo4j/index.d.ts new file mode 100644 index 0000000000..f0923557ca --- /dev/null +++ b/neo4j/index.d.ts @@ -0,0 +1,278 @@ +// Type definitions for node-neo4j 2.0.0 +// Project: https://github.com/thingdom/node-neo4j +// Definitions by: Cyril Schumacher +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Request } from "request"; + +type ResultCallback = (error: any, result: any) => void; +type DoneCallback = (error: any) => void; + +/** + * Authentication information. + * @interface + */ +export interface Authentication { + password: string; + username: string; +} + +/** + * Password options. + * @interface + */ +export interface ChangePasswordOptions { + password: string; +} + +/** + * Constraint options. + * @interface + */ +export interface ConstraintOptions { + label?: any; + property?: any; +} + +/** + * Cypher request options. + * @interface + */ +export interface CypherOptions { + commit?: {}; + headers?: {}; + lean?: {}; + params?: {}; + query?: {}; +} + +/** + * Database options. + * @interface + */ +export interface GraphDatabaseOptions { + /** + * HTTP agent. + * @type {any} + */ + agent: any; + + /** + * Authentication information. + * @type {string|Authentication} + */ + auth: string | Authentication; + + /** + * HTTP headers. + * @type {Object} + */ + headers: {}; + + /** + * Proxy address. + * @type {string} + */ + proxy: string; + + /** + * URL connection. + * @type {string} + */ + url: string; +} + +/** + * HTTP options. + * @interface + */ +export interface HttpOptions { + headers: {}; + method: string; + path: string; + body: any; + raw: any; +} + +/** + * Index options. + * @interface + */ +export interface IndexOptions { + label?: any; + property?: any; +} + +/** + * Transaction. + * @interface + */ +export interface Transaction { + expiresAt: Date; + expiresIn: Date | number; + state: string; + + commit(callback: DoneCallback): void; + cypher(options: CypherOptions, callback: ResultCallback): Request; + renew(callback: DoneCallback): void; + rollback(callback: DoneCallback): void; +} + +/** + * Database. + * @class + */ +export class GraphDatabase { + /** + * Constructor. + * @constructor + * @param {string} url A URL connection. + */ + constructor(url: string); + + /** + * Constructor. + * @constructor + * @param {GraphDatabaseOptions} options Connection options. + */ + constructor(options: GraphDatabaseOptions); + + /** + * Agent. + * @type {any} + */ + agent: any; + + /** + * Credentials. + * @type {Authentication} + */ + auth: Authentication; + + /** + * Headers. + * @type {Object} + */ + headers: {}; + + /** + * Proxy. + * @type {any} + */ + proxy: any; + + /** + * URL connection. + * @type {string} + */ + url: string; + + /** + * Makes multiple queries, across multiple network requests, all within a single transaction. + * @return {Transaction} The transaction. + */ + beginTransaction(): Transaction; + + /** + * Changes password. + * @param {ChangePasswordOptions} options Options. + * @param {DoneCallback} callback A callback. + */ + changePassword(options: ChangePasswordOptions, callback: DoneCallback): void; + + /** + * Checks if the password must be changed. + * @param {Function} callback A callback. + */ + checkPasswordChangeNeeded(callback: (error: any, changed: boolean) => void): void; + + /** + * Creates a constraint. + * @param {ConstraintOptions} options Options. + * @param {ResultCallback} callback A callback. + */ + createConstraint(options: ConstraintOptions, callback: ResultCallback): void; + + /** + * Makes simple, parametrized Cypher queries. + * @param {CypherOptions} options Options. + * @param {ResultCallback} callback A callback. + */ + cypher(options: CypherOptions, callback: ResultCallback): Request; + + /** + * Drops a constraint. + * @param {ConstraintOptions} options Options. + * @param {DoneCallback} callback A callback. + */ + dropConstraint(options: ConstraintOptions, callback: DoneCallback): void; + + /** + * Drop an index. + * @param {IndexOptions} options Options. + * @param {DoneCallback} callback A callback. + */ + dropIndex(options: IndexOptions, callback: DoneCallback): void; + + /** + * Gets constraints. + * @param {ConstraintOptions} options Options or callback. + * @param {ResultCallback} callback A callback. + */ + getConstraints(options: ConstraintOptions, callback?: ResultCallback): void; + + /** + * Gets indexes. + * @param {ResultCallback} callback A callback. + */ + getIndexes(callback?: ResultCallback): void; + + /** + * Gets indexes. + * @param {IndexOptions} options Options. + * @param {ResultCallback} callback A callback. + */ + getIndexes(options: IndexOptions, callback: ResultCallback): void; + + /** + * Get labels. + * @param {ResultCallback} callback A callback. + */ + getLabels(callback: ResultCallback): void; + + /** + * Gets property keys. + * @param {ResultCallback} callback A callback. + */ + getPropertyKeys(callback: ResultCallback): void; + + /** + * Gets relationship types. + * @param {ResultCallback} callback A callback. + */ + getRelationshipTypes(callback: ResultCallback): void; + + /** + * Determines if a constraint exists. + * @param {ConstraintOptions} options Options. + * @param {Function} callback A callback. + */ + hasConstraint(options: ConstraintOptions, callback: (error: any, exists: boolean) => void): void; + + /** + * Determines if an index exists. + * @param {IndexOptions} options Options. + * @param {Function} callback A callback. + */ + hasIndex(options: IndexOptions, callback: (error: any, exists: boolean) => void): void; + + /** + * Makes arbitrary HTTP request to the REST API. + * @param {HttpOptions} options Options. + * @param {ResultCallback} callback A callback. + * @return {Request} The HTTP request. + */ + http(options: HttpOptions, callback: ResultCallback): Request; +} diff --git a/neo4j/neo4j-tests.ts b/neo4j/neo4j-tests.ts new file mode 100644 index 0000000000..3745e025f5 --- /dev/null +++ b/neo4j/neo4j-tests.ts @@ -0,0 +1,55 @@ +import * as neo4j from "neo4j"; + +let db = new neo4j.GraphDatabase("http://localhost:7474"); +db = new neo4j.GraphDatabase({ + url: 'http://localhost:7474', + auth: { + password: "", + username: "" + }, + headers: {}, + proxy: "", + agent: null +}); + +/** Password */ +db.checkPasswordChangeNeeded((error: any, changed: boolean) => { }); +db.changePassword({ password: "" }, (error: any) => { }); + +/** Query */ +db.cypher({ query: 'MATCH (u:User {email: {email}}) RETURN u', params: { email: 'alice@example.com' } }, (error: any, results: any) => { }); + +/** Constraint */ +db.createConstraint({ label: "", property: "" }, (error: any, constraint: any) => { }); +db.dropConstraint({ label: "", property: "" }, (error: any) => { }); +db.getConstraints({ label: "", property: "" }, (error: any, constraints: any) => { }); +db.hasConstraint({ label: "", property: "" }, (error: any, exists: boolean) => { }); + +/** Index */ +db.dropIndex({ label: "", property: "" }, (error: any) => { }); +db.getIndexes((error: any, indexes: any) => { }); +db.getIndexes({ label: "", property: "" }, (error: any, indexes: any) => { }); +db.hasIndex({ label: "", property: "" }, (error: any, exists: boolean) => { }); + +/** Labels */ +db.getLabels((error: any, labels: any) => { }); + +/** Property keys */ +db.getPropertyKeys((error: any, keys: any) => { }); + +/** Relationship */ +db.getRelationshipTypes((error: any, types: any) => { }); + +/** HTTP */ +db.http({ method: "", path: "", headers: {}, body: "", raw: "" }, (error: any, body: any) => { }); + +/** Transaction */ +const transaction: neo4j.Transaction = db.beginTransaction(); +transaction.rollback((error: any) => { }); +transaction.commit((error: any) => { }); +transaction.renew((error: any) => { }); +transaction.cypher({ query: 'MATCH (u:User {email: {email}}) RETURN u', params: { email: 'alice@example.com' } }, (error: any, results: any) => { }); + +const expiresIn: Date | number = transaction.expiresIn; +const expiresAt: Date = transaction.expiresAt; +const state: string = transaction.state diff --git a/neo4j/tsconfig.json b/neo4j/tsconfig.json new file mode 100644 index 0000000000..dd3a543a23 --- /dev/null +++ b/neo4j/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "neo4j-tests.ts" + ] +} From d056f0b650b6700d3506d985ad234d684b53577e Mon Sep 17 00:00:00 2001 From: Mike Haas Date: Tue, 15 Nov 2016 14:06:33 -0500 Subject: [PATCH 15/24] Make comp ctrl locals param scope optional (#12659) IComponentControllerService ($componentController) has a second param, locals, which allows for an optional scope key to be provided. This fixes the typing to make that property actually optional. You can see that here https://docs.angularjs.org/guide/component#unit-testing-component-controllers and here https://docs.angularjs.org/api/ngMock/service/$componentController --- angular-mocks/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-mocks/index.d.ts b/angular-mocks/index.d.ts index e3ef7bad18..3c24ed1cf6 100644 --- a/angular-mocks/index.d.ts +++ b/angular-mocks/index.d.ts @@ -107,7 +107,7 @@ declare module 'angular' { interface IComponentControllerService { // TBinding is an interface exposed by a component as per John Papa's style guide // https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#accessible-members-up-top - (componentName: string, locals: { $scope: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T; + (componentName: string, locals: { $scope?: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T; } From cd4b2b6aa19dda8b7c21ce079f70814b1bda7579 Mon Sep 17 00:00:00 2001 From: Artem Roshko Date: Wed, 16 Nov 2016 00:07:19 +0500 Subject: [PATCH 16/24] Optional parameters for Option interface (#12681) --- react-select/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-select/index.d.ts b/react-select/index.d.ts index 1d98fb2a72..6ee7d498b1 100644 --- a/react-select/index.d.ts +++ b/react-select/index.d.ts @@ -20,9 +20,9 @@ declare namespace ReactSelectClass { export interface Option { /** Text for rendering */ - label: string; + label?: string; /** Value for searching */ - value: string | number; + value?: string | number; /** * Allow this option to be cleared * @default true From e1fb8319cf7e0a79fd5ffb39e5f797e024faa2b7 Mon Sep 17 00:00:00 2001 From: Klemens Date: Tue, 15 Nov 2016 20:29:53 +0100 Subject: [PATCH 17/24] Update videojs.d.ts - Adding playbackRate(rate) (#12699) Adding playbackRate(rate) method - see http://docs.videojs.com/docs/api/player.html#MethodsplaybackRate --- videojs/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/videojs/index.d.ts b/videojs/index.d.ts index 3ac6007daf..9e4156ece6 100644 --- a/videojs/index.d.ts +++ b/videojs/index.d.ts @@ -53,6 +53,7 @@ interface VideoJSPlayer { addRemoteTextTrack(options : {}) : HTMLTrackElement; removeRemoteTextTrack(track : HTMLTrackElement) : void; poster(val?: string) : string|VideoJSPlayer; + playbackRate(rate?: number) : number; } interface VideoJSStatic { From c6f86d519ce91fa805bee4f2eb49263d321cd5b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Podeszwa?= Date: Tue, 15 Nov 2016 20:32:27 +0100 Subject: [PATCH 18/24] Add typings for humanname 1.1.1 (#12641) --- humanparser/humanparser-tests.ts | 19 ++++++++++++++++ humanparser/index.d.ts | 37 ++++++++++++++++++++++++++++++++ humanparser/tsconfig.json | 19 ++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 humanparser/humanparser-tests.ts create mode 100644 humanparser/index.d.ts create mode 100644 humanparser/tsconfig.json diff --git a/humanparser/humanparser-tests.ts b/humanparser/humanparser-tests.ts new file mode 100644 index 0000000000..0abe741554 --- /dev/null +++ b/humanparser/humanparser-tests.ts @@ -0,0 +1,19 @@ +import human = require('humanparser'); + +let parsedName = human.parseName("Mr. William R. Hearst, III"); +parsedName.firstName; +parsedName.lastName; +parsedName.fullName; +parsedName.suffix; +parsedName.middleName; +parsedName.salutation; + +let parsedAddress = human.parseAddress("123 Happy Street, Honolulu, HI 65780"); +parsedAddress.address; +parsedAddress.state; +parsedAddress.fullAddress; +parsedAddress.zip; +parsedAddress.city; + +let parsedFullName = human.getFullestName("John & Peggy Sue"); +parsedFullName.fullName; diff --git a/humanparser/index.d.ts b/humanparser/index.d.ts new file mode 100644 index 0000000000..37209a60f3 --- /dev/null +++ b/humanparser/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for humanparser 1.1.1 +// Project: https://github.com/chovy/humanparser +// Definitions by: Michał Podeszwa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace humanparser { + interface NameOutput { + firstName: string; + lastName: string; + fullName: string; + suffix?: string; + middleName?: string; + salutation?: string; + } + + interface FullerNameOutput { + fullName: string; + } + + interface AddressOutput { + address: string; + state: string; + fullAddress: string; + zip: string; + city: string; + } + + interface HumanparserStatic { + parseName (name: string): NameOutput; + getFullestName (name: string): FullerNameOutput; + parseAddress (address: string): AddressOutput; + } + +} + +declare const humanparser: humanparser.HumanparserStatic; +export = humanparser; diff --git a/humanparser/tsconfig.json b/humanparser/tsconfig.json new file mode 100644 index 0000000000..17b129eba5 --- /dev/null +++ b/humanparser/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "humanparser-tests.ts" + ] +} From 3561e140bd9ec6c1dfd39d4ba350346044181fd0 Mon Sep 17 00:00:00 2001 From: Jacek Jagiello Date: Tue, 15 Nov 2016 21:56:00 +0100 Subject: [PATCH 19/24] Code review fixes --- react-hot-loader/index.d.ts | 23 ++++++++++------------- react-hot-loader/tsconfig.json | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/react-hot-loader/index.d.ts b/react-hot-loader/index.d.ts index 202566a5b4..9987a4f28f 100644 --- a/react-hot-loader/index.d.ts +++ b/react-hot-loader/index.d.ts @@ -1,20 +1,17 @@ -// Type definitions for react-hot-loader 3.0.0-beta.6 +// Type definitions for react-hot-loader 3.0 // Project: https://github.com/gaearon/react-hot-loader // Definitions by: Jacek Jagiello // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as React from "react" -declare module "react-hot-loader" { - - interface ErrorReporterProps { - error: any - } - - export interface AppContainerProps { - children?: React.ReactElement, - errorReporter?: React.ComponentClass | React.StatelessComponent - } - - export class AppContainer extends React.Component {} +interface ErrorReporterProps { + error: any } + +export interface AppContainerProps { + children?: React.ReactElement, + errorReporter?: React.ComponentClass | React.StatelessComponent +} + +export class AppContainer extends React.Component {} diff --git a/react-hot-loader/tsconfig.json b/react-hot-loader/tsconfig.json index a25cbaa2ed..f24a0d4bca 100644 --- a/react-hot-loader/tsconfig.json +++ b/react-hot-loader/tsconfig.json @@ -3,7 +3,7 @@ "module": "commonjs", "target": "es6", "noImplicitAny": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "jsx": "react", "typeRoots": [ From 33338d5b114aee07706fa4f9dcdeffec7c33ced5 Mon Sep 17 00:00:00 2001 From: michaelneu Date: Sat, 12 Nov 2016 22:57:47 +0100 Subject: [PATCH 20/24] Add definitions for voronoi-diagram --- voronoi-diagram/index.d.ts | 18 ++++++++++++++++++ voronoi-diagram/tsconfig.json | 19 +++++++++++++++++++ voronoi-diagram/voronoi-diagram-tests.ts | 14 ++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 voronoi-diagram/index.d.ts create mode 100644 voronoi-diagram/tsconfig.json create mode 100644 voronoi-diagram/voronoi-diagram-tests.ts diff --git a/voronoi-diagram/index.d.ts b/voronoi-diagram/index.d.ts new file mode 100644 index 0000000000..4f0811d3d3 --- /dev/null +++ b/voronoi-diagram/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for voronoi-diagram 1.0.1 +// Project: https://github.com/mikolalysenko/voronoi-diagram +// Definitions by: Michael Neu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "voronoi-diagram" { + type Point = number[]; + type Cell = number[]; + type Position = number[]; + + interface VoronoiDiagram { + cells: Cell[]; + positions: Position[]; + } + + function voronoi(points: Point[]) : VoronoiDiagram; + export = voronoi; +} \ No newline at end of file diff --git a/voronoi-diagram/tsconfig.json b/voronoi-diagram/tsconfig.json new file mode 100644 index 0000000000..384e19c9b1 --- /dev/null +++ b/voronoi-diagram/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "voronoi-diagram-tests.ts" + ] +} \ No newline at end of file diff --git a/voronoi-diagram/voronoi-diagram-tests.ts b/voronoi-diagram/voronoi-diagram-tests.ts new file mode 100644 index 0000000000..3cd6bb667f --- /dev/null +++ b/voronoi-diagram/voronoi-diagram-tests.ts @@ -0,0 +1,14 @@ +/// + +import voronoi = require("voronoi-diagram"); + +let points = [ + [1, 1], + [2, 2], + [3, 3] +]; + +let diagram = voronoi(points); + +let firstCell = diagram.cells[0], + firstPosition = diagram.positions[0]; \ No newline at end of file From 0fbab808e078fdce36a37cf40c150a6f43302a8f Mon Sep 17 00:00:00 2001 From: michaelneu Date: Wed, 16 Nov 2016 00:09:42 +0100 Subject: [PATCH 21/24] use external module style in voronoi-diagram --- voronoi-diagram/index.d.ts | 12 ++++----- voronoi-diagram/tsconfig.json | 34 ++++++++++++------------ voronoi-diagram/voronoi-diagram-tests.ts | 5 +++- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/voronoi-diagram/index.d.ts b/voronoi-diagram/index.d.ts index 4f0811d3d3..2926777823 100644 --- a/voronoi-diagram/index.d.ts +++ b/voronoi-diagram/index.d.ts @@ -3,16 +3,16 @@ // Definitions by: Michael Neu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "voronoi-diagram" { +declare namespace voronoi { type Point = number[]; type Cell = number[]; - type Position = number[]; interface VoronoiDiagram { cells: Cell[]; - positions: Position[]; + positions: Point[]; } +} - function voronoi(points: Point[]) : VoronoiDiagram; - export = voronoi; -} \ No newline at end of file +declare function voronoi(points: voronoi.Point[]) : voronoi.VoronoiDiagram; + +export = voronoi; \ No newline at end of file diff --git a/voronoi-diagram/tsconfig.json b/voronoi-diagram/tsconfig.json index 384e19c9b1..1347450427 100644 --- a/voronoi-diagram/tsconfig.json +++ b/voronoi-diagram/tsconfig.json @@ -1,19 +1,19 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "voronoi-diagram-tests.ts" - ] + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "voronoi-diagram-tests.ts" + ] } \ No newline at end of file diff --git a/voronoi-diagram/voronoi-diagram-tests.ts b/voronoi-diagram/voronoi-diagram-tests.ts index 3cd6bb667f..31b261e1ce 100644 --- a/voronoi-diagram/voronoi-diagram-tests.ts +++ b/voronoi-diagram/voronoi-diagram-tests.ts @@ -2,7 +2,10 @@ import voronoi = require("voronoi-diagram"); -let points = [ +const x: voronoi.Point = [1, 2]; + +let points: voronoi.Point[] = [ + x, [1, 1], [2, 2], [3, 3] From 405632732790f87f31d0c9c097b62af868f37acf Mon Sep 17 00:00:00 2001 From: heycalmdown Date: Wed, 16 Nov 2016 10:35:23 +0900 Subject: [PATCH 22/24] Adopt recent reviews by @andy-ms --- msgpack5/index.d.ts | 44 +++++++++++++-------------------------- msgpack5/msgpack5-test.ts | 35 +++++++++++++++++++++++++++---- 2 files changed, 46 insertions(+), 33 deletions(-) diff --git a/msgpack5/index.d.ts b/msgpack5/index.d.ts index ceb02cc758..f2d0382182 100644 --- a/msgpack5/index.d.ts +++ b/msgpack5/index.d.ts @@ -6,46 +6,32 @@ import stream = require('stream'); import bl = require('bl'); -interface Options { - forceFloat64: boolean; - compatibilityMode: boolean; +interface MsgPackOptions { + forceFloat64?: boolean; + compatibilityMode?: boolean; } declare namespace msgpack5 { - interface Options { + interface EncodeDecodeOptions { header?: boolean; - msgpack?: any; } - class Base extends stream.Transform { - protected _header: any; - protected _msgpack: any; - } - - class Encoder extends Base { - constructor(opts?: Options); - public _transform(obj: any, enc: any, done: Function): any; - } - - class Decoder extends Base { - constructor(opts?: Options); - public _chunks: bl; - public _length: number; - public _transform(buf: any, enc: any, done: Function): any; - } + class Base extends stream.Transform {} + class Encoder extends Base {} + class Decoder extends Base {} interface MessagePack { encode(obj: any): bl; - decode(buf: Buffer): T; - decode(buf: bl): T; - register(type: number, $constructor: any, encode: (obj: any) => Buffer, decode: (data: Buffer) => any): any; - registerEncoder(check: (obj: any) => boolean, encode: (obj: any) => Buffer): any; - registerDecoder(type: number, decode: (data: Buffer) => any): any; - encoder(opts?: Options): Encoder; - decoder(opts?: Options): Decoder; + decode(buf: Buffer): any; + decode(buf: bl): any; + register(type: number, $constructor: any, encode: (obj: T) => Buffer, decode: (data: Buffer) => T): MessagePack; + registerEncoder(check: (obj: T) => boolean, encode: (obj: T) => Buffer): MessagePack; + registerDecoder(type: number, decode: (data: Buffer) => any): MessagePack; + encoder(opts?: EncodeDecodeOptions): Encoder; + decoder(opts?: EncodeDecodeOptions): Decoder; } } -declare function msgpack5(opts?: Options): msgpack5.MessagePack; +declare function msgpack5(opts?: MsgPackOptions): msgpack5.MessagePack; export = msgpack5; diff --git a/msgpack5/msgpack5-test.ts b/msgpack5/msgpack5-test.ts index ad2d86d9a6..6cd9854992 100644 --- a/msgpack5/msgpack5-test.ts +++ b/msgpack5/msgpack5-test.ts @@ -1,6 +1,33 @@ -import * as msgpack5 from 'msgpack5'; +import * as msgpack from 'msgpack5'; -const packer = msgpack5(); -const IN = {}; -const OUT = packer.decode(packer.encode(IN)); +// msgpack() +let packer = msgpack(); +packer = msgpack({ forceFloat64: true }); +packer = msgpack({ compatibilityMode: true }); +class InputType { + number: number; + string: string; + + constructor() { + this.number = 1; + this.string = '1'; + } +} + +// msgpack().encode, msgpack().decode() +const IN: InputType = new InputType(); +const encoded = packer.encode(IN); +const OUT: InputType = packer.decode(encoded); + +// msgpack().registerEncoder(), msgpack().registerDecoder() +packer = packer.registerEncoder((o: InputType) => true, (o: InputType) => new Buffer('')); +packer = packer.registerDecoder(0x01, (data) => ({ content: { number: 1, string: '1' }})); + +// msgpack().register() +packer = packer.register(0x01, InputType, (obj: InputType) => new Buffer(''), (data: Buffer) => (new InputType())); + +// msgpack().encoder(), msgpack().decoder() +const encoder = packer.encoder(); +const decoder = packer.decoder(); +encoder.pipe(decoder); From 1674dea52b678b92e5806d05bda90e01d399437a Mon Sep 17 00:00:00 2001 From: Michael Scharf Date: Wed, 16 Nov 2016 03:24:55 +0100 Subject: [PATCH 23/24] analytics-node export Analytics class as described in the docs (#12707) This fixes #12706. According to the [documentation](https://segment.com/docs/sources/server/node/), an instance is supposed to be created like this: ```js var Analytics = require('analytics-node'); var analytics = new Analytics('YOUR_WRITE_KEY'); ``` --- analytics-node/analytics-node-tests.ts | 6 +++--- analytics-node/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/analytics-node/analytics-node-tests.ts b/analytics-node/analytics-node-tests.ts index 594c15fae6..5207fe560b 100644 --- a/analytics-node/analytics-node-tests.ts +++ b/analytics-node/analytics-node-tests.ts @@ -1,8 +1,8 @@ -import AnalyticsNode = require("analytics-node"); -var analytics: AnalyticsNode.Analytics; +import Analytics = require("analytics-node"); +var analytics: Analytics; function testConfig(): void { - analytics = new AnalyticsNode.Analytics('YOUR_WRITE_KEY', { + analytics = new Analytics('YOUR_WRITE_KEY', { flushAt: 20, flushAfter: 10000 }); diff --git a/analytics-node/index.d.ts b/analytics-node/index.d.ts index 455b13c92b..fa0b8d6426 100644 --- a/analytics-node/index.d.ts +++ b/analytics-node/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Andrew Fong // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = AnalyticsNode; +export = AnalyticsNode.Analytics; declare namespace AnalyticsNode { From 96896fe428882f9e92fff5d1f2b5bad34c6bcbe9 Mon Sep 17 00:00:00 2001 From: DavidM77 Date: Wed, 16 Nov 2016 02:26:58 +0000 Subject: [PATCH 24/24] Added type definitions for metric-suffix (#12704) --- metric-suffix/index.d.ts | 10 +++++++++ metric-suffix/metric-suffix-external-tests.ts | 22 +++++++++++++++++++ metric-suffix/metric-suffix-tests.ts | 20 +++++++++++++++++ metric-suffix/tsconfig.json | 20 +++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 metric-suffix/index.d.ts create mode 100644 metric-suffix/metric-suffix-external-tests.ts create mode 100644 metric-suffix/metric-suffix-tests.ts create mode 100644 metric-suffix/tsconfig.json diff --git a/metric-suffix/index.d.ts b/metric-suffix/index.d.ts new file mode 100644 index 0000000000..8a3875c460 --- /dev/null +++ b/metric-suffix/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for metric-suffix.js 0.0.3 +// Project: https://github.com/mstdokumaci/metric-suffix.js +// Definitions by: David Muller +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export as namespace metric_suffix; + +export = metric_suffix; + +declare function metric_suffix(value: number, precision?: number): string; \ No newline at end of file diff --git a/metric-suffix/metric-suffix-external-tests.ts b/metric-suffix/metric-suffix-external-tests.ts new file mode 100644 index 0000000000..5b22aeeaa1 --- /dev/null +++ b/metric-suffix/metric-suffix-external-tests.ts @@ -0,0 +1,22 @@ +import metric_suffix = require('metric-suffix'); + +metric_suffix(42) // 42 +metric_suffix(999) // 999 +metric_suffix(1000) // 1.0k + +metric_suffix(1234, 2) // 1.2k +metric_suffix(12345, 2) // 12k +metric_suffix(123456, 2) // 123k + +metric_suffix(1234, 3) // 1.23k +metric_suffix(12345, 3) // 12.3k +metric_suffix(123456, 3) // 123k + +metric_suffix(1234, 4) // 1.234k +metric_suffix(12345, 4) // 12.35k +metric_suffix(123456, 4) // 123.5k + +metric_suffix(986725) // 987k +metric_suffix(986725, 4) // 986.7k +metric_suffix(986725123) // 987M +metric_suffix(986725123, 5) // 986.73M \ No newline at end of file diff --git a/metric-suffix/metric-suffix-tests.ts b/metric-suffix/metric-suffix-tests.ts new file mode 100644 index 0000000000..eb88d6240f --- /dev/null +++ b/metric-suffix/metric-suffix-tests.ts @@ -0,0 +1,20 @@ +metric_suffix(42) // 42 +metric_suffix(999) // 999 +metric_suffix(1000) // 1.0k + +metric_suffix(1234, 2) // 1.2k +metric_suffix(12345, 2) // 12k +metric_suffix(123456, 2) // 123k + +metric_suffix(1234, 3) // 1.23k +metric_suffix(12345, 3) // 12.3k +metric_suffix(123456, 3) // 123k + +metric_suffix(1234, 4) // 1.234k +metric_suffix(12345, 4) // 12.35k +metric_suffix(123456, 4) // 123.5k + +metric_suffix(986725) // 987k +metric_suffix(986725, 4) // 986.7k +metric_suffix(986725123) // 987M +metric_suffix(986725123, 5) // 986.73M \ No newline at end of file diff --git a/metric-suffix/tsconfig.json b/metric-suffix/tsconfig.json new file mode 100644 index 0000000000..3d2a6c7d7a --- /dev/null +++ b/metric-suffix/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "metric-suffix-tests.ts", + "metric-suffix-external-tests.ts" + ] +} \ No newline at end of file