From 61efe0aca839c83016a2b5ae599063bde51cd09e Mon Sep 17 00:00:00 2001 From: xkxx Date: Sun, 10 Dec 2017 16:39:36 -0800 Subject: [PATCH] [misc] Add 'ss' relative time key to typescript definition (#4246) * Add 'ss' to typescript definition * add missing ss key to MomentRelativetime * add typing tests for new ss key * correct whitespacing issues --- moment.d.ts | 6 ++++-- typing-tests/moment-tests.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/moment.d.ts b/moment.d.ts index 24667a3f5..cdca9da0f 100644 --- a/moment.d.ts +++ b/moment.d.ts @@ -2,7 +2,7 @@ declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSp declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, language?: string, strict?: boolean): moment.Moment; declare namespace moment { - type RelativeTimeKey = 's' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'M' | 'MM' | 'y' | 'yy'; + type RelativeTimeKey = 's' | 'ss' | 'm' | 'mm' | 'h' | 'hh' | 'd' | 'dd' | 'M' | 'MM' | 'y' | 'yy'; type CalendarKey = 'sameDay' | 'nextDay' | 'lastDay' | 'nextWeek' | 'lastWeek' | 'sameElse' | string; type LongDateFormatKey = 'LTS' | 'LT' | 'L' | 'LL' | 'LLL' | 'LLLL' | 'lts' | 'lt' | 'l' | 'll' | 'lll' | 'llll'; @@ -82,6 +82,7 @@ declare namespace moment { future: RelativeTimeFuturePastVal; past: RelativeTimeFuturePastVal; s: RelativeTimeSpecVal; + ss: RelativeTimeSpecVal; m: RelativeTimeSpecVal; mm: RelativeTimeSpecVal; h: RelativeTimeSpecVal; @@ -215,6 +216,7 @@ declare namespace moment { future: any; past: any; s: any; + ss: any; m: any; mm: any; h: any; @@ -408,7 +410,7 @@ declare namespace moment { strict?: boolean; } - interface Moment extends Object{ + interface Moment extends Object { format(format?: string): string; startOf(unitOfTime: unitOfTime.StartOf): Moment; diff --git a/typing-tests/moment-tests.ts b/typing-tests/moment-tests.ts index af635ca7c..bafdf1175 100644 --- a/typing-tests/moment-tests.ts +++ b/typing-tests/moment-tests.ts @@ -302,6 +302,7 @@ moment.locale('en', { future: "in %s", past: "%s ago", s: "seconds", + ss: "%d seconds", m: "a minute", mm: "%d minutes", h: "an hour", @@ -446,6 +447,7 @@ moment.locale('en', { future: "in %s", past: "%s ago", s: "seconds", + ss: "%d seconds", m: "a minute", mm: "%d minutes", h: "an hour", -- 2.47.2