From a6448a411a037ecfead7ba0f4d2eb24de8efce8b Mon Sep 17 00:00:00 2001 From: Gabriel JUCHAULT Date: Tue, 23 Aug 2016 13:27:40 +0200 Subject: [PATCH] Fix countdown types --- countdown/countdown-tests.ts | 10 +++++----- countdown/countdown.d.ts | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/countdown/countdown-tests.ts b/countdown/countdown-tests.ts index c803f1acc2..3ad8890aab 100644 --- a/countdown/countdown-tests.ts +++ b/countdown/countdown-tests.ts @@ -1,15 +1,15 @@ /// -import { countdown, Timespan, CountdownStatic, Format } from 'countdown'; +import * as countdown from 'countdown'; -let ts: Timespan; +let ts: countdown.Timespan; let interval: number; -ts = countdown(new Date()); -ts = countdown(150); +ts = countdown(new Date()); +ts = countdown(150); interval = countdown(new Date(), - function (ts: Timespan) { + function (ts: countdown.Timespan) { document.getElementById('pageTimer').innerHTML = ts.toHTML('strong'); }, countdown.HOURS | countdown.MINUTES | countdown.SECONDS, diff --git a/countdown/countdown.d.ts b/countdown/countdown.d.ts index 5b40541dd0..bcb0d07976 100644 --- a/countdown/countdown.d.ts +++ b/countdown/countdown.d.ts @@ -3,11 +3,11 @@ // Definitions by: Gabriel Juchault // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'countdown' { - export type DateFunction = (timespan: Timespan) => void; - export type DateTime = number | Date | DateFunction; +declare namespace countdown { + type DateFunction = (timespan: Timespan) => void; + type DateTime = number | Date | DateFunction; - export interface Timespan { + interface Timespan { start?: Date; end?: Date; units?: number; @@ -26,7 +26,7 @@ declare module 'countdown' { toHTML(tagName?: string, label?: string): string; } - export interface Format { + interface Format { singular?: string | Array; plural?: string | Array; last?: string; @@ -36,7 +36,7 @@ declare module 'countdown' { formatter?(value: number, unit: number): string; } - export interface CountdownStatic { + interface CountdownStatic { (start: DateTime, end?: DateTime, units?: number, max?: number, digits?: number): Timespan | number; MILLENNIA: number; CENTURIES: number; @@ -64,6 +64,9 @@ declare module 'countdown' { resetFormat(): void; setFormat(format: Format): void; } - - export let countdown: CountdownStatic; +} + +declare module 'countdown' { + let countdown: countdown.CountdownStatic; + export = countdown; }