diff --git a/types/moment-precise-range-plugin/index.d.ts b/types/moment-precise-range-plugin/index.d.ts new file mode 100644 index 0000000000..ad28b3d009 --- /dev/null +++ b/types/moment-precise-range-plugin/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for moment-precise-range 0.2 +// Project: https://github.com/codebox/moment-precise-range +// Definitions by: Mitchell Grice +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import moment = require('moment'); + +export = moment; + +declare module "moment" { + interface PreciseRangeValueObject { + years: number; + months: number; + days: number; + hours: number; + minutes: number; + seconds: number; + firstDateWasLater: boolean; + } + + interface Moment { + preciseDiff(d2: Moment, returnValueObject?: false): string; + preciseDiff(d2: Moment, returnValueObject: true): PreciseRangeValueObject; + } + + function preciseDiff(d1: Moment, d2: Moment, returnValueObject?: false): string; + function preciseDiff(d1: Moment, d2: Moment, returnValueObject: true): PreciseRangeValueObject; +} diff --git a/types/moment-precise-range-plugin/moment-precise-range-plugin-tests.ts b/types/moment-precise-range-plugin/moment-precise-range-plugin-tests.ts new file mode 100644 index 0000000000..427d513fb9 --- /dev/null +++ b/types/moment-precise-range-plugin/moment-precise-range-plugin-tests.ts @@ -0,0 +1,14 @@ +import moment = require("moment"); +import * as momentPreciseRange from "moment-precise-range-plugin"; + +// Static methods +const m1 = moment.utc(); +const m2 = moment.utc(); +moment.preciseDiff(m1, m2); +moment.preciseDiff(m1, m2, true); +moment.preciseDiff(m1, m2, false); + +// Instance methods +m1.preciseDiff(m2); +m1.preciseDiff(m2, true); +m1.preciseDiff(m2, false); diff --git a/types/moment-precise-range-plugin/package.json b/types/moment-precise-range-plugin/package.json new file mode 100644 index 0000000000..19e5fb0d14 --- /dev/null +++ b/types/moment-precise-range-plugin/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.14.0" + } +} diff --git a/types/moment-precise-range-plugin/tsconfig.json b/types/moment-precise-range-plugin/tsconfig.json new file mode 100644 index 0000000000..cfb6dcbd4d --- /dev/null +++ b/types/moment-precise-range-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moment-precise-range-plugin-tests.ts" + ] +} diff --git a/types/moment-precise-range-plugin/tslint.json b/types/moment-precise-range-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-precise-range-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }