From 460302420194baed69f57e5fdfbcf45e0cb9ba5b Mon Sep 17 00:00:00 2001 From: Matt Traynham Date: Mon, 2 Oct 2017 15:21:31 -0400 Subject: [PATCH] Add type definitions for webpack-chunk-hash plugin (#20145) --- types/webpack-chunk-hash/index.d.ts | 34 +++++++++++++++++++ types/webpack-chunk-hash/tsconfig.json | 22 ++++++++++++ types/webpack-chunk-hash/tslint.json | 1 + .../webpack-chunk-hash-tests.ts | 15 ++++++++ 4 files changed, 72 insertions(+) create mode 100644 types/webpack-chunk-hash/index.d.ts create mode 100644 types/webpack-chunk-hash/tsconfig.json create mode 100644 types/webpack-chunk-hash/tslint.json create mode 100644 types/webpack-chunk-hash/webpack-chunk-hash-tests.ts diff --git a/types/webpack-chunk-hash/index.d.ts b/types/webpack-chunk-hash/index.d.ts new file mode 100644 index 0000000000..dc8f697a44 --- /dev/null +++ b/types/webpack-chunk-hash/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for webpack-chunk-hash 0.4 +// Project: https://github.com/alexindigo/webpack-chunk-hash#readme +// Definitions by: Matt Traynham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import webpack = require('webpack'); + +export = WebpackChunkHash; + +declare class WebpackChunkHash extends webpack.Plugin { + constructor(options?: WebpackChunkHash.Options); +} + +declare namespace WebpackChunkHash { + interface Options { + /** + * @default 'md5' + * @description The hash algorithm to use + * @see {@link https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options} + */ + algorithm?: string; + /** + * @default 'hex' + * @description The digest enconding to use + * @see {@link https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options} + */ + digest?: 'hex' | 'latin1' | 'base64'; + /** + * @default null + * @description A callback to add more content to the resulting hash + */ + additionalHashContent?(chunk: any): string; + } +} diff --git a/types/webpack-chunk-hash/tsconfig.json b/types/webpack-chunk-hash/tsconfig.json new file mode 100644 index 0000000000..1d6e971b9d --- /dev/null +++ b/types/webpack-chunk-hash/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "webpack-chunk-hash-tests.ts" + ] +} diff --git a/types/webpack-chunk-hash/tslint.json b/types/webpack-chunk-hash/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/webpack-chunk-hash/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/webpack-chunk-hash/webpack-chunk-hash-tests.ts b/types/webpack-chunk-hash/webpack-chunk-hash-tests.ts new file mode 100644 index 0000000000..56a7be1579 --- /dev/null +++ b/types/webpack-chunk-hash/webpack-chunk-hash-tests.ts @@ -0,0 +1,15 @@ +import webpack = require('webpack'); +import WebpackChunkHashPlugin = require('webpack-chunk-hash'); + +const a: webpack.Configuration = { + entry: 'test.js', + plugins: [ + new WebpackChunkHashPlugin() + ] +}; +const b: webpack.Configuration = { + entry: 'test.js', + plugins: [ + new WebpackChunkHashPlugin({algorithm: 'sha-256', digest: 'latin1', additionalHashContent: () => 'test'}) + ] +};