From 9f9210d7af2ebe1356fee4f16b8807af364a00e1 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 19 Oct 2016 16:04:00 +0200 Subject: [PATCH 1/4] Fixed types for ora v0.3.0 --- ora/index.d.ts | 52 +++++++++++++++++++++++++++++------------------- ora/ora-tests.ts | 3 +-- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/ora/index.d.ts b/ora/index.d.ts index e58b5575c7..f5db7383e7 100644 --- a/ora/index.d.ts +++ b/ora/index.d.ts @@ -1,25 +1,37 @@ -// Type definitions for ora +// Type definitions for ora v0.3.0 // Project: https://github.com/sindresorhus/ora -// Definitions by: Basarat Ali Syed +// Definitions by: Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// -type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; -type Text = string; -interface Options { - text?: Text; - spinner?: string | { interval?: number; frames: string[]; } - color?: Color; - stream?: any; +declare module "ora" { + type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; + type Text = string; + interface Options { + text?: Text; + spinner?: string | Spinner; + color?: Color; + interval?: number; + stream?: NodeJS.WritableStream; + enabled?: boolean; + } + interface Spinner { + interval?: number; + frames: string[]; + } + interface Instance { + start(): Instance; + stop(): Instance; + succeed(): Instance; + fail(): Instance; + stopAndPersist(symbol?: string): Instance; + clear(): Instance; + render(): Instance; + frame(): Instance; + text: string; + color: Color; + } + function ora(options: Options | Text): Instance; + export = ora; } -interface Instance { - start(): void; - stop(): void; - clear(): void; - frame(): void; - render(): void; - text: Text; - color: Color; -} -declare function ora(options: Options | Text): Instance; -export = ora; diff --git a/ora/ora-tests.ts b/ora/ora-tests.ts index 7116db78ce..32e39aa753 100644 --- a/ora/ora-tests.ts +++ b/ora/ora-tests.ts @@ -1,8 +1,7 @@ import ora = require('ora'); -const spinner = ora('Loading unicorns'); -spinner.start(); +const spinner = ora('Loading unicorns').start(); setTimeout(() => { spinner.color = 'yellow'; From f572efa5593cb23f4f0003ec811b62a0d36a240c Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Thu, 20 Oct 2016 06:48:41 +0200 Subject: [PATCH 2/4] Fixed names in // Definitions --- ora/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ora/index.d.ts b/ora/index.d.ts index f5db7383e7..6e06bd35ec 100644 --- a/ora/index.d.ts +++ b/ora/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for ora v0.3.0 // Project: https://github.com/sindresorhus/ora -// Definitions by: Christian Rackerseder +// Definitions by: Basarat Ali Syed , Christian Rackerseder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 14eed8a1fef49ef9543dd9a75a5622afb23ade30 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Wed, 26 Oct 2016 07:34:34 +0200 Subject: [PATCH 3/4] Replaced Text with string --- ora/index.d.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ora/index.d.ts b/ora/index.d.ts index 6e06bd35ec..976005200b 100644 --- a/ora/index.d.ts +++ b/ora/index.d.ts @@ -7,9 +7,8 @@ declare module "ora" { type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; - type Text = string; interface Options { - text?: Text; + text?: string; spinner?: string | Spinner; color?: Color; interval?: number; @@ -32,6 +31,6 @@ declare module "ora" { text: string; color: Color; } - function ora(options: Options | Text): Instance; + function ora(options: Options | string): Instance; export = ora; } From a27693680c4fcde005f99ceeb2f4b1182c76ee7b Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Thu, 27 Oct 2016 11:21:39 +0200 Subject: [PATCH 4/4] Removed declare module "ora" --- ora/index.d.ts | 54 ++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/ora/index.d.ts b/ora/index.d.ts index 976005200b..e45a585442 100644 --- a/ora/index.d.ts +++ b/ora/index.d.ts @@ -5,32 +5,30 @@ /// -declare module "ora" { - type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; - interface Options { - text?: string; - spinner?: string | Spinner; - color?: Color; - interval?: number; - stream?: NodeJS.WritableStream; - enabled?: boolean; - } - interface Spinner { - interval?: number; - frames: string[]; - } - interface Instance { - start(): Instance; - stop(): Instance; - succeed(): Instance; - fail(): Instance; - stopAndPersist(symbol?: string): Instance; - clear(): Instance; - render(): Instance; - frame(): Instance; - text: string; - color: Color; - } - function ora(options: Options | string): Instance; - export = ora; +type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray'; +interface Options { + text?: string; + spinner?: string | Spinner; + color?: Color; + interval?: number; + stream?: NodeJS.WritableStream; + enabled?: boolean; } +interface Spinner { + interval?: number; + frames: string[]; +} +interface Instance { + start(): Instance; + stop(): Instance; + succeed(): Instance; + fail(): Instance; + stopAndPersist(symbol?: string): Instance; + clear(): Instance; + render(): Instance; + frame(): Instance; + text: string; + color: Color; +} +declare function ora(options: Options | string): Instance; +export = ora;