[javascript-time-ago] Fix types (#42269)

* Fix javascript-time-ago types

* Enhanced types

* Fix types

* Fix files entries

* Fix files entries

* Fix files entries

* Fix files entries

* Fix files entries

* Fix files entries

* Fix files entries
This commit is contained in:
Luis Felipe Zaguini
2020-02-19 15:33:48 -08:00
committed by GitHub
parent 955e667056
commit 94e71fe291
10 changed files with 86 additions and 4 deletions
+1 -1
View File
@@ -128,4 +128,4 @@ locale/gu/index.d.ts
locale/ms/index.d.ts
locale/ro/index.d.ts
locale/ka/index.d.ts
locale/ti/index.d.ts
locale/ti/index.d.ts
+5
View File
@@ -0,0 +1,5 @@
import { Gradation } from './';
declare const canonical: Gradation[];
export default canonical;
+5
View File
@@ -0,0 +1,5 @@
import { Gradation } from './';
declare const convenient: Gradation[];
export default convenient;
+9
View File
@@ -0,0 +1,9 @@
import { Gradation, Unit } from '.';
export const minute: number;
export const hour: number;
export const day: number;
export const month: number;
export const year: number;
export function getStep(gradation: Gradation[], unit: Unit): Gradation | undefined;
export function getDate(value: Date | number): Date;
+20
View File
@@ -0,0 +1,20 @@
export type Unit = 'now' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
export interface Gradation {
unit?: Unit;
factor?: number;
granularity?: number;
threshold?: number;
threshold_for_now?: number;
threshold_for_second?: number;
threshold_for_minute?: number;
threshold_for_hour?: number;
threshold_for_day?: number;
threshold_for_week?: number;
threshold_for_month?: number;
threshold_for_year?: number;
}
export { default as canonical } from './canonical';
export { default as convenient } from './convenient';
export { minute, hour, day, month, year, getStep, getDate } from './helpers';
+11 -3
View File
@@ -2,16 +2,24 @@
// Project: https://github.com/catamphetamine/javascript-time-ago
// Definitions by: Erik Burton <https://github.com/erikburt>
// Henry Nguyen <https://github.com/HenryNguyen5>
// Luis Felipe Zaguini <https://github.com/zaguiini>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Locale, TimeUnit, Duration, DefaultFormats, RTFFormatter, Formats, QuantifyType } from "./locale";
import {
DefaultFormats,
Duration,
Formats,
Locale,
RTFFormatter,
TimeUnit
} from './locale';
import { FormatStyle } from './style';
export = TimeAgo;
declare class TimeAgo {
constructor(locales?: string | string[]);
format(input: Date | number, style?: string): string;
format(input: Date | number, style?: string | FormatStyle): string;
formatNumber(number: number): string;
formatValue(value: Date | number, unit: TimeUnit, localeData: Duration): string;
getFormatter(flavor: DefaultFormats): RTFFormatter;
+3
View File
@@ -0,0 +1,3 @@
import { FormatStyle } from './index';
export default FormatStyle;
+26
View File
@@ -0,0 +1,26 @@
import { Gradation, Unit } from '../gradation';
import { Locale } from '../locale';
export type Flavour = 'tiny' | 'short-time' | 'narrow' | 'short' | 'long';
export interface CustomFormatterOptions {
now: number;
date?: Date;
time: number;
elapsed: number;
locale: Locale;
}
export type CustomFormatter = (options: CustomFormatterOptions) => string | undefined;
export interface FormatStyle {
units?: Unit;
gradation?: Gradation[];
flavour?: Flavour[];
custom?: CustomFormatter;
format?(date: Date | number, locale: Locale): string;
}
export { default as timeStyle } from './time';
export { default as twitterStyle } from './twitter';
export { default as defaultStyle } from './default';
+3
View File
@@ -0,0 +1,3 @@
import { FormatStyle } from './index';
export default FormatStyle;
+3
View File
@@ -0,0 +1,3 @@
import { FormatStyle } from './index';
export default FormatStyle;