Add types for write-file-webpack-plugin (#45374)

This commit is contained in:
Nathan Hardy 2020-06-16 19:50:34 +10:00 committed by GitHub
parent feb6196347
commit 2252c4f5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,43 @@
// Type definitions for write-file-webpack-plugin 4.5
// Project: https://github.com/gajus/write-file-webpack-plugin#readme
// Definitions by: Nathan Hardy <https://github.com/nhardy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import webpack = require("webpack");
export interface UserOptionsType {
/**
* Atomically replace files content (i.e., to prevent programs like test watchers from seeing partial files).
* @default true
*/
atomicReplace?: boolean;
/**
* Stop writing files on webpack errors
* @default true
*/
exitOnErrors?: boolean;
/**
* A regular expression or function used to test if file should be written.
* When not present, all bundle will be written.
*/
test?: RegExp;
/**
* Use hash index to write only files that have changed since the last iteration.
* @default true
*/
useHashIndex?: boolean;
/**
* Logs names of the files that are being written (or skipped because they have not changed)
* @default true
*/
log?: boolean;
/**
* Forces the execution of the plugin regardless of being using `webpack-dev-server` or not
* @default false
*/
force?: boolean;
}
export default class WriteFilePlugin extends webpack.Plugin {
constructor(userOptions?: UserOptionsType);
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"write-file-webpack-plugin-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,15 @@
import webpack = require("webpack");
import WriteFileWebpackPlugin from "write-file-webpack-plugin";
export const plugins: webpack.Plugin[] = [
new WriteFileWebpackPlugin(),
new WriteFileWebpackPlugin({}),
new WriteFileWebpackPlugin({
atomicReplace: false,
exitOnErrors: false,
test: /\.css$/,
useHashIndex: false,
log: false,
force: true,
}),
];