diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..84b7166 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist-* \ No newline at end of file diff --git a/.npmignore b/.npmignore index 286dfcc..1a1f43e 100644 --- a/.npmignore +++ b/.npmignore @@ -8,3 +8,4 @@ !README.md !package.json !index.js +!index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..22c8ec4 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for webpack-dashboard 2.x.x +// Project: https://github.com/FormidableLabs/webpack-dashboard +// Definitions by: Parker Ziegler +// TypeScript Version: 3.2 + +declare module 'webpack-dashboard/plugin' { + interface IMessage { + type: string; + value: string | number | { [key: string]: any } + error?: boolean; + } + + interface IDashboardOptions { + port?: number; + host?: string; + handler?: (dataArray: IMessage[]) => void; + } + + class DashboardPlugin { + constructor(options?: IDashboardOptions); + } + + export = DashboardPlugin; +} \ No newline at end of file diff --git a/package.json b/package.json index 9b11e39..ea1f8ec 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,14 @@ "engines": { "node": ">=6.0.0" }, + "types": "index.d.ts", "scripts": { "test": "mocha 'test/**/*.spec.js'", "test-cov": "nyc mocha 'test/**/*.spec.js'", "lint": "eslint .", - "check": "npm run lint && npm run test", - "check-ci": "npm run lint && npm run test-cov", + "check": "npm run lint && npm run test && npm run check-ts", + "check-ci": "npm run lint && npm run test-cov && npm run check-ts", + "check-ts": "tsc index.d.ts --noEmit", "dev": "cross-env EXAMPLE=duplicates-esm node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.js --watch" }, "repository": { @@ -58,6 +60,7 @@ "nyc": "^11.8.0", "sinon": "^5.0.7", "sinon-chai": "^3.0.0", + "typescript": "^3.2.4", "webpack": "^4.8.3", "webpack-cli": "^2.1.3", "webpack-stats-plugin": "^0.2.1" diff --git a/yarn.lock b/yarn.lock index 6a1e0cd..ae6ef46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6163,6 +6163,11 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= +typescript@^3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d" + integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg== + uglify-es@^3.3.4: version "3.3.9" resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"