Add type definitions for webpack-chunk-hash plugin (#20145)

This commit is contained in:
Matt Traynham
2017-10-02 12:21:31 -07:00
committed by Ryan Cavanaugh
parent ab5cdaf0ac
commit 4603024201
4 changed files with 72 additions and 0 deletions
+34
View File
@@ -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 <https://github.com/mtraynham>
// 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;
}
}
+22
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -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'})
]
};