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

Add typescript definition #210

Open
wants to merge 1 commit into
base: master
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Type definitions for moment-jalaali 0.7.0
// Project: https://github.com/jalaali/moment-jalaali
// Definitions by: Ali Taheri Moghaddar <https://github.com/alitaheri>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

import moment = require("moment");

export = moment;

declare module "moment" {
type JUnitOfTime = "jYear" | "jMonth";

interface LoadPersianOptions {
/**
* Use persian digits as decribed by unicode
*/
usePersianDigits?: boolean;
/**
* use dialect option to change usePersian dialect, available options are:
* persian: default dialect(امرداد، آدینه، ...)
* persian-modern: modern dialect(مرداد، جمعه، ...)
*/
dialect?: "persian" | "persian-modern";
}

/**
* Add persian language.
*/
function loadPersian(options?: LoadPersianOptions): void;

function jIsLeapYear(year: number): boolean;
function jDaysInMonth(year: number, month: number): number;

interface Moment {
startOf(jUnitOfTime: JUnitOfTime): Moment;
endOf(jUnitOfTime: JUnitOfTime): Moment;

add(amount: string | number, jUnitOfTime: JUnitOfTime): Moment;

subtract(amount: string | number, jUnitOfTime: JUnitOfTime): Moment;

jYear(y: number): Moment;
jYear(): number;
jMonth(M: number | string): Moment;
jMonth(): number;
jDate(d: number): Moment;
jDate(): number;
jWeek(d: number): Moment;
jWeek(): number;
jWeekYear(d: number): Moment;
jWeekYear(): number;
jDayOfYear(d: number): Moment;
jDayOfYear(): number;
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"convert"
],
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "mocha --reporter spec --ui bdd --colors --check-leaks test.js",
"lint": "eslint index.js && eslint --env mocha --rule 'no-unused-expressions: 0' test.js",
Expand All @@ -45,4 +46,4 @@
"moment-timezone": "^0.5.21",
"rimraf": "^2.6.2"
}
}
}