]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[bugfix] More complete type definitions for strict formatless parsing #4611 (#5574)
authorGeorgii Dolzhykov <thorn.mailbox@gmail.com>
Tue, 15 Sep 2020 02:32:03 +0000 (05:32 +0300)
committerGitHub <noreply@github.com>
Tue, 15 Sep 2020 02:32:03 +0000 (19:32 -0700)
* Reflect changes from #4611 in ts3.1-typings

* Add types for `moment.utc(..., true)`

moment.d.ts
ts3.1-typing-tests/moment-tests.ts
ts3.1-typings/moment.d.ts

index 97c29bdf1abac9cd87315b9797b18d776addf3dc..bd9d87b836a9ed265c10deeb9a07652b859ef5f8 100644 (file)
@@ -4,13 +4,13 @@
  */
 declare function moment(inp?: moment.MomentInput, strict?: boolean): moment.Moment;
 /**
- * @param strict Strict parsing requires that the format and input match exactly, including delimeters.
+ * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  */
 declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, strict?: boolean): moment.Moment;
 /**
- * @param strict Strict parsing requires that the format and input match exactly, including delimeters.
+ * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
  * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
  * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
  */
@@ -663,7 +663,22 @@ declare namespace moment {
   export var fn: Moment;
 
   // NOTE(constructor): Same as moment constructor
+  /**
+   * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when
+   * parsing a string.
+   */
+  export function utc(inp?: MomentInput, strict?: boolean): Moment;
+  /**
+   * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+   * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+   * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+   */
   export function utc(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
+  /**
+   * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+   * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+   * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+   */
   export function utc(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
 
   export function unix(timestamp: number): Moment;
index a04d56af146718a6c4d75635649e055c9956efc8..a7ddc5d08f651cb1632291802d495e4791e4930f 100644 (file)
@@ -23,6 +23,8 @@ var day10 = moment([2010, 6, 10]);
 var array = [2010, 1, 14, 15, 25, 50, 125];
 var day11 = moment(Date.UTC.apply({}, array));
 var day12 = moment.unix(1318781876);
+var day13 = moment("/Date(1198908717056-0700)/", true);
+var day14 = moment("foobazbar", 'L', true);
 
 moment(null);
 moment(undefined);
index 6b82f995347a31daaf5133deceaa0a403bfc65b2..a04270f6600333a03c857590cdc823f9a402e354 100644 (file)
@@ -1,4 +1,19 @@
+/**
+ * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when
+ * parsing a string.
+ */
+declare function moment(inp?: moment.MomentInput, strict?: boolean): moment.Moment;
+/**
+ * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+ * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+ * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+ */
 declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, strict?: boolean): moment.Moment;
+/**
+ * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+ * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+ * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+ */
 declare function moment(inp?: moment.MomentInput, format?: moment.MomentFormatSpecification, language?: string, strict?: boolean): moment.Moment;
 
 declare namespace moment {
@@ -636,7 +651,22 @@ declare namespace moment {
   export var fn: Moment;
 
   // NOTE(constructor): Same as moment constructor
+  /**
+   * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when
+   * parsing a string.
+   */
+  export function utc(inp?: MomentInput, strict?: boolean): Moment;
+  /**
+   * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+   * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+   * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+   */
   export function utc(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment;
+  /**
+   * @param strict Strict parsing requires that the format and input match exactly, including delimiters.
+   * Strict parsing is frequently the best parsing option. For more information about choosing strict vs
+   * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/).
+   */
   export function utc(inp?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
 
   export function unix(timestamp: number): Moment;