From 3420691dd9dbc807799d0e44043a45acd583dffb Mon Sep 17 00:00:00 2001 From: Michael Zabka Date: Wed, 12 Nov 2014 21:56:42 +0100 Subject: [PATCH 1/2] Added typings for npm module each * git: https://github.com/wdavidw/node-each --- each/each-tests.ts | 41 +++++++++++++++++++++++++++++++++++++++++ each/each.d.ts | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 each/each-tests.ts create mode 100644 each/each.d.ts diff --git a/each/each-tests.ts b/each/each-tests.ts new file mode 100644 index 000000000..370e6ac39 --- /dev/null +++ b/each/each-tests.ts @@ -0,0 +1,41 @@ +/// +/// + +function testEach() { + var EachStaticClass: EachStatic = function (array: any[]) { + return { + paused: true, + readable: false, + started: true, + done: true, + total: true, + on: function (eventName: string, cb: (a: any, b?: () => void) => void) { + return EachStaticClass([]); + }, + parallel: function (mode: any) { + return EachStaticClass([]); + }, + shift: function (items: any[]) {}, + write: function (items: any[]) {}, + unshift: function (items: any[]) {}, + end: function () { + return EachStaticClass([]); + }, + times: function () { + return EachStaticClass([]); + }, + repeat: function () { + return EachStaticClass([]); + }, + sync: function () { + return EachStaticClass([]); + }, + files: function (a: any, glob?: any) {} + }; + }; + + var each: Each = EachStaticClass([1, 2, 3]); + + var EachReq: EachStatic = require("each"); + var each: Each = EachReq([4, 5, 6]); +} diff --git a/each/each.d.ts b/each/each.d.ts new file mode 100644 index 000000000..65d0a3f9d --- /dev/null +++ b/each/each.d.ts @@ -0,0 +1,39 @@ +// Type definitions for NodeEach v0.4.9 +// Project: http://www.adaltas.com/projects/node-each/ +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Each { + paused: boolean; + readable: boolean; + started: boolean; + done: boolean; + total: boolean; + on(eventName: string, onCallback: Function): Each; + on(eventName: "item", onItem: (item: any, next: (error?: Error) => void) => void): Each; + on(eventName: "error", onError: (error: Error[]) => void): Each; + on(eventName: "error", onError: (error: Error) => void): Each; + on(eventName: "both", onBoth: (error?: Error[]) => void): Each; + on(eventName: "end", onEnd: () => void): Each; + parallel(mode: number): Each; + parallel(mode: boolean): Each; + shift(items: any[]): void; + write(items: any[]): void; + unshift(items: any[]): void; + end(): Each; + times(): Each; + repeat(): Each; + sync(): Each; + files(glob: any): void; + files(base: any, glob: any): void; +} + +interface EachStatic { + (array: any[]): Each; +} + +declare var each: EachStatic; + +declare module "each" { + export = each; +} \ No newline at end of file From fcc948753530a2661e7cf3afd4428566f5182f4a Mon Sep 17 00:00:00 2001 From: Michael Zabka Date: Wed, 19 Nov 2014 18:40:43 +0100 Subject: [PATCH 2/2] Added typings for npm module traceback * git: https://github.com/iriscouch/traceback --- traceback/traceback-tests.ts | 29 +++++++++++++++++++++++++++++ traceback/traceback.d.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 traceback/traceback-tests.ts create mode 100644 traceback/traceback.d.ts diff --git a/traceback/traceback-tests.ts b/traceback/traceback-tests.ts new file mode 100644 index 000000000..d0772b597 --- /dev/null +++ b/traceback/traceback-tests.ts @@ -0,0 +1,29 @@ +/// +/// + +function testTraceback() { + var TracebackStaticClass: TracebackStatic = function () { + return [{ + name: 'some', + path: 'nice', + file: 'good', + line: 113, + col: 32, + pos: 43, + fun: {'x-x': 'any'}, + method: 'like', + this: { no: "thing"}, + type: 'goal', + origin: ['bad'], + is_top: true, + is_eval: false, + is_native: true, + is_ctor: true + }]; + }; + + var traceback: Traceback[] = TracebackStaticClass(); + + var TBReq: TracebackStatic = require('traceback'); + var traceback: Traceback[] = TBReq(); +} diff --git a/traceback/traceback.d.ts b/traceback/traceback.d.ts new file mode 100644 index 000000000..4ea2992ec --- /dev/null +++ b/traceback/traceback.d.ts @@ -0,0 +1,32 @@ +// Type definitions for Traceback v0.3.1 +// Project: http://github.com/iriscouch/traceback +// Definitions by: Michael Zabka +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Traceback { + name: string; // | The function name + path: string; // | The absolute path of the file defining the function + file: string; // | The basename of the path file ("example.js") + line: number; // | The line number in the file + col: number; // | The column number in the file + pos: number; // | The byte position in the file + fun: any; // | The function itself + method: string; // | If this function was called as a method, the name it is stored as + this: any; // | The object bound to the label this in the function + type: string; // | The type of this; the name of the constructor function (Object, ReadStream, etc.) + origin: any; // | The CallSite that ran eval(), if this frame is an eval + is_top: boolean; // | Boolean indicating whether the function was called with a global this + is_eval: boolean; // | Boolean indicating whether the function comes from an eval() call + is_native: boolean; // | Boolean indicating whether the function is native + is_ctor: boolean; // | Boolean indicating whether this is a constructor (new) call +} + +interface TracebackStatic { + (): Traceback[]; +} + +declare var traceback: TracebackStatic; + +declare module "traceback" { + export = traceback; +}