Add types for webpack-watched-glob-entries-plugin

This commit is contained in:
Joel Spadin
2019-03-03 01:25:32 -06:00
parent a722795328
commit 874d94e033
4 changed files with 70 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for webpack-watched-glob-entries-plugin 2.1
// Project: https://github.com/Milanzor/webpack-watched-glob-entries-plugin#readme
// Definitions by: Joel Spadin <https://github.com/ChaosinaCan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { IOptions } from 'glob';
import { EntryFunc, Plugin } from 'webpack';
export interface PluginOptions {
basename_as_entry_name?: boolean;
}
export default class WebpackWatchedGlobEntries extends Plugin {
static getEntries(globs: string[], globOptions?: IOptions, pluginOptions?: PluginOptions): EntryFunc;
static getFiles(globString: string, globOptions?: IOptions, basename_as_entry_name?: boolean): Record<string, string>;
}
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpack-watched-glob-entries-plugin-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,29 @@
import GlobEntriesPlugin from 'webpack-watched-glob-entries-plugin';
new GlobEntriesPlugin(); // $ExpectType WebpackWatchedGlobEntries
GlobEntriesPlugin.getEntries(['']); // $ExpectType EntryFunc
// $ExpectType EntryFunc
GlobEntriesPlugin.getEntries([''], {
ignore: ''
});
// $ExpectType EntryFunc
GlobEntriesPlugin.getEntries([''], {
ignore: '',
}, {
basename_as_entry_name: true,
});
GlobEntriesPlugin.getFiles(''); // $ExpectType Record<string, string>
// $ExpectType Record<string, string>
GlobEntriesPlugin.getFiles('', {
ignore: '',
});
// $ExpectType Record<string, string>
GlobEntriesPlugin.getFiles('', {
ignore: '',
}, true);