Skip to content

Commit

Permalink
Fix for issue moment#6202: appended null as return type for toJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
utf26 committed Mar 21, 2024
1 parent 18aba13 commit 2687a27
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion moment.d.ts
Expand Up @@ -589,7 +589,7 @@ declare namespace moment {
toDate(): Date;
toISOString(keepOffset?: boolean): string;
inspect(): string;
toJSON(): string;
toJSON(): string | null;
unix(): number;

isLeapYear(): boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/test/moment/to_type.js
Expand Up @@ -29,6 +29,8 @@ test('toDate returns a copy of the internal date', function (assert) {
});

test('toJSON', function (assert) {
assert.strictEqual(moment(null).toJSON(), null, 'toJSON null');

if (Date.prototype.toISOString) {
var expected = new Date().toISOString();
assert.deepEqual(moment(expected).toJSON(), expected, 'toJSON invalid');
Expand Down

0 comments on commit 2687a27

Please sign in to comment.