add string-replace-webpack-plugin types

This commit is contained in:
Rongjian Zhang
2018-10-29 10:39:31 +08:00
parent 3d82362c03
commit 00de285b6a
3 changed files with 64 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
// Type definitions for string-replace-webpack-plugin 0.1.3
// Project: https://github.com/jamesandersen/string-replace-webpack-plugin
// Definitions by: Rongjian Zhang <https://github.com/pd4d10>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin, RuleSetUse } from 'webpack';
export = StringReplacePlugin;
declare class StringReplacePlugin extends Plugin {
static replace(
options: StringReplacePlugin.Options,
/**
* loaders to follow the replacement
*/
nextLoaders?: string
): RuleSetUse;
static replace(
/**
* loaders to apply prior to the replacement
*/
prevLoaders: string,
options: StringReplacePlugin.Options,
/**
* loaders to follow the replacement
*/
nextLoaders?: string
): RuleSetUse;
}
declare namespace StringReplacePlugin {
interface Options {
replacements: ReplacementItem[];
}
interface ReplacementItem {
/**
* a regex to match against the file contents
*/
pattern: RegExp;
/**
* an ECMAScript string replacement function
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter
*/
replacement: (substring: string, ...args: any[]) => string;
}
}
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "string-replace-webpack-plugin-tests.ts"]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }