mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Fix countdown types
This commit is contained in:
@@ -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,
|
||||
|
||||
19
countdown/countdown.d.ts
vendored
19
countdown/countdown.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user