mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
[script-ext-html-webpack-plugin] Add initial types
This commit is contained in:
79
types/script-ext-html-webpack-plugin/index.d.ts
vendored
Normal file
79
types/script-ext-html-webpack-plugin/index.d.ts
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
// Type definitions for script-ext-html-webpack-plugin 2.1
|
||||
// Project: https://github.com/numical/script-ext-html-webpack-plugin
|
||||
// Definitions by: Dave Cardwell <https://github.com/davecardwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Plugin } from "webpack";
|
||||
|
||||
export = ScriptExtHtmlWebpackPlugin;
|
||||
|
||||
declare class ScriptExtHtmlWebpackPlugin extends Plugin {
|
||||
constructor(options?: ScriptExtHtmlWebpackPlugin.Options);
|
||||
}
|
||||
|
||||
type ScriptMatchingPatternBase =
|
||||
| string
|
||||
| RegExp
|
||||
| ReadonlyArray<string | RegExp>;
|
||||
|
||||
interface ScriptMatchingPatternHash {
|
||||
test: ScriptMatchingPatternBase;
|
||||
}
|
||||
|
||||
type ScriptMatchingPattern =
|
||||
| ScriptMatchingPatternBase
|
||||
| ScriptMatchingPatternHash;
|
||||
|
||||
type ScriptMatchingPatternPre =
|
||||
| ScriptMatchingPatternBase
|
||||
| ScriptMatchingPatternHash & {
|
||||
chunks?: "initial" | "async" | "all";
|
||||
};
|
||||
|
||||
interface Custom {
|
||||
test: ScriptMatchingPattern;
|
||||
attribute: string;
|
||||
value?: string;
|
||||
}
|
||||
|
||||
declare namespace ScriptExtHtmlWebpackPlugin {
|
||||
interface Options {
|
||||
/**
|
||||
* scripts that should be inlined in the html (default: `[]`)
|
||||
*/
|
||||
inline?: ScriptMatchingPattern;
|
||||
/**
|
||||
* script names that should have no attribute (default: `[]`)
|
||||
*/
|
||||
sync?: ScriptMatchingPattern;
|
||||
/**
|
||||
* script names that should have an async attribute (default: `[]`)
|
||||
*/
|
||||
async?: ScriptMatchingPattern;
|
||||
/**
|
||||
* script names that should have a defer attribute (default: `[]`)
|
||||
*/
|
||||
defer?: ScriptMatchingPattern;
|
||||
/**
|
||||
* the default attribute to set - 'sync' actually results in no attribute (default: 'sync')
|
||||
*/
|
||||
defaultAttribute?: "sync" | "async" | "defer";
|
||||
/**
|
||||
* script names that should have a type="module" attribute (default: `[]`)
|
||||
*/
|
||||
module?: ScriptMatchingPattern;
|
||||
/**
|
||||
* scripts that should have accompanying preload resource hints (default: `[]`)
|
||||
*/
|
||||
preload?: ScriptMatchingPatternPre;
|
||||
/**
|
||||
* scripts that should have accompanying prefetch resource hints (default: `[]`)
|
||||
*/
|
||||
prefetch?: ScriptMatchingPatternPre;
|
||||
/**
|
||||
* scripts that should have a custom attribute(s) added, the attribute(s), and the value(s)
|
||||
*/
|
||||
custom?: Custom | Custom[];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import ScriptExtHtmlWebpackPlugin = require("script-ext-html-webpack-plugin");
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin();
|
||||
new ScriptExtHtmlWebpackPlugin({});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: "string",
|
||||
sync: "string",
|
||||
async: "string",
|
||||
defer: "string",
|
||||
module: "string",
|
||||
preload: "string",
|
||||
prefetch: "string"
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: ["array"],
|
||||
sync: ["array"],
|
||||
async: ["array"],
|
||||
defer: ["array"],
|
||||
module: ["array"],
|
||||
preload: ["array"],
|
||||
prefetch: ["array"]
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: /regexp/,
|
||||
sync: /regexp/,
|
||||
async: /regexp/,
|
||||
defer: /regexp/,
|
||||
module: /regexp/,
|
||||
preload: /regexp/,
|
||||
prefetch: /regexp/
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: { test: "string" },
|
||||
sync: { test: "string" },
|
||||
async: { test: "string" },
|
||||
defer: { test: "string" },
|
||||
module: { test: "string" },
|
||||
preload: { test: "string" },
|
||||
prefetch: { test: "string" }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: { test: ["array"] },
|
||||
sync: { test: ["array"] },
|
||||
async: { test: ["array"] },
|
||||
defer: { test: ["array"] },
|
||||
module: { test: ["array"] },
|
||||
preload: { test: ["array"] },
|
||||
prefetch: { test: ["array"] }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
inline: { test: /regexp/ },
|
||||
sync: { test: /regexp/ },
|
||||
async: { test: /regexp/ },
|
||||
defer: { test: /regexp/ },
|
||||
module: { test: /regexp/ },
|
||||
preload: { test: /regexp/ },
|
||||
prefetch: { test: /regexp/ }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
preload: { test: "string", chunks: "initial" },
|
||||
prefetch: { test: "string", chunks: "initial" }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
preload: { test: "string", chunks: "async" },
|
||||
prefetch: { test: "string", chunks: "async" }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
preload: { test: "string", chunks: "all" },
|
||||
prefetch: { test: "string", chunks: "all" }
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({ defaultAttribute: "sync" });
|
||||
new ScriptExtHtmlWebpackPlugin({ defaultAttribute: "async" });
|
||||
new ScriptExtHtmlWebpackPlugin({ defaultAttribute: "defer" });
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
custom: {
|
||||
test: "string",
|
||||
attribute: "string"
|
||||
}
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
custom: {
|
||||
test: ["array"],
|
||||
attribute: "string",
|
||||
value: "string"
|
||||
}
|
||||
});
|
||||
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
custom: [
|
||||
{
|
||||
test: /regexp/,
|
||||
attribute: "string"
|
||||
},
|
||||
{
|
||||
test: "string",
|
||||
attribute: "string",
|
||||
value: "string"
|
||||
}
|
||||
]
|
||||
});
|
||||
16
types/script-ext-html-webpack-plugin/tsconfig.json
Normal file
16
types/script-ext-html-webpack-plugin/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "script-ext-html-webpack-plugin-tests.ts"]
|
||||
}
|
||||
1
types/script-ext-html-webpack-plugin/tslint.json
Normal file
1
types/script-ext-html-webpack-plugin/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user