Skip to content

Commit

Permalink
added typings
Browse files Browse the repository at this point in the history
  • Loading branch information
smartin85 committed Apr 19, 2017
1 parent ce70e1b commit 9b75f59
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 18 deletions.
10 changes: 6 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module.exports = function (config) {
const package = require('./package.json');
//console.log(package);
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [
'node_modules/moment/moment.js',
'tests/moment-timezone-with-data.js',
'tests/unit-tests/moment-timezone-with-data.js',
'moment-dt.js',
'tests/moment-dt.spec.js'
'tests/unit-tests/moment-dt.spec.js'
],
exclude: [],
reporters: ['progress', 'coverage', 'coveralls'],
Expand All @@ -23,10 +25,10 @@ module.exports = function (config) {
'karma-eslint'
],
globals: {
packageVersion: require('./package.json').version
packageVersion: package.version
},
preprocessors: {
'tests/moment-dt.spec.js': ['global', 'eslint'],
'tests/unit-tests/moment-dt.spec.js': ['global', 'eslint'],
'moment-dt.js': ['coverage', 'eslint']
},
coverageReporter: {
Expand Down
22 changes: 22 additions & 0 deletions moment-dt.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as moment from 'moment-timezone';

declare module "moment-timezone" {
interface MomentTsTz {
ts: number;
tz: string;
}

interface Moment {
dt(): MomentTsTz;
}

interface MomentDt {
(dt: MomentTsTz): moment.Moment;
version: string;
}

const dt: MomentDt;
}

// require("moment-dt") === require("moment-timezone")
export = moment;
2 changes: 1 addition & 1 deletion moment-dt.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
}(this, function (moment) {

var VERSION = "1.0.1";
var VERSION = "1.0.2";

/* istanbul ignore if */
if (!moment.tz) {
Expand Down
2 changes: 1 addition & 1 deletion moment-dt.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"name": "moment-dt",
"version": "1.0.1",
"version": "1.0.2",
"description": "Convert timestamp-with-timezone-objects from and to moment.js",
"main": "moment-dt.js",
"typings": "./moment-dt.d.ts",
"scripts": {
"test": "npm run prod:test",
"test": "run-s prod:test:*",
"start": "run-p dev:*",
"dev:test": "karma start",
"build": "run-s prod:*",
"prod:minify": "uglifyjs --compress --mangle -- moment-dt.js > moment-dt.min.js",
"prod:test": "karma start --singleRun"
"prod:test:unit": "karma start --singleRun",
"prod:test:typings": "tsc --project tests/typings-tests"
},
"repository": {
"type": "git",
Expand All @@ -28,20 +30,22 @@
},
"homepage": "https://github.com/smartin85/moment-dt#readme",
"dependencies": {
"@types/moment-timezone": "^0.2.34",
"moment": ">= 2.8.1 <3.0.0",
"moment-timezone": "^0.5.11"
},
"devDependencies": {
"jasmine-core": "~2.5.2",
"jasmine-core": "2.5.2",
"karma": "1.6.0",
"karma-chrome-launcher": "~2.0.0",
"karma-coverage": "^1.1.1",
"karma-coveralls": "^1.1.2",
"karma-eslint": "^2.2.0",
"karma-global-preprocessor": "~0.0.2",
"karma-jasmine": "~1.1.0",
"karma-phantomjs-launcher": "~1.0.2",
"npm-run-all": "^4.0.2",
"karma-chrome-launcher": "2.0.0",
"karma-coverage": "1.1.1",
"karma-coveralls": "1.1.2",
"karma-eslint": "2.2.0",
"karma-global-preprocessor": "0.0.2",
"karma-jasmine": "1.1.0",
"karma-phantomjs-launcher": "1.0.4",
"npm-run-all": "4.0.2",
"typescript": "2.2.2",
"uglify-js": "2.8.22"
}
}
8 changes: 8 additions & 0 deletions tests/typings-tests/moment-dt-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference path="../../moment-dt.d.ts" />
import moment = require('../../moment-dt');


var timezone: string = moment().tz();
var dt:{ts: number, tz: string} = moment().dt();
var mom: moment.Moment = moment.dt({ts: 1492630664, tz: "Europe/Berlin"});
var version: string = moment.dt.version;
12 changes: 12 additions & 0 deletions tests/typings-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"noEmit": true,
"noImplicitAny": true
},
"files": [
"../../moment-dt.d.ts",
"./moment-dt-tests.ts"
]
}
File renamed without changes.
File renamed without changes.

0 comments on commit 9b75f59

Please sign in to comment.