Fix countdown types

This commit is contained in:
Gabriel JUCHAULT
2016-08-23 13:27:40 +02:00
parent 73e7125348
commit a6448a411a
2 changed files with 16 additions and 13 deletions

View File

@@ -1,15 +1,15 @@
/// <reference path="countdown.d.ts" />
import { countdown, Timespan, CountdownStatic, Format } from 'countdown';
import * as countdown from 'countdown';
let ts: Timespan;
let ts: countdown.Timespan;
let interval: number;
ts = <Timespan>countdown(new Date());
ts = <Timespan>countdown(150);
ts = <countdown.Timespan>countdown(new Date());
ts = <countdown.Timespan>countdown(150);
interval = <number>countdown(new Date(),
function (ts: Timespan) {
function (ts: countdown.Timespan) {
document.getElementById('pageTimer').innerHTML = ts.toHTML('strong');
},
countdown.HOURS | countdown.MINUTES | countdown.SECONDS,

View File

@@ -3,11 +3,11 @@
// Definitions by: Gabriel Juchault <https://github.com/gjuchault>
// 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<string>;
plural?: string | Array<string>;
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;
}