Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #6202: Append 'null' as Return Type for toJSON Method in TypeScript Definitions #6221

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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