mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
feat: add declarations for sw-precache-webpack-plugin (#25541)
* feat: add declarations for sw-precache-webpack-plugin * override type of sw-precache option `importScripts`
This commit is contained in:
parent
b14a53f475
commit
e8849415f2
38
types/sw-precache-webpack-plugin/index.d.ts
vendored
Normal file
38
types/sw-precache-webpack-plugin/index.d.ts
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Type definitions for sw-precache-webpack-plugin 0.11
|
||||
// Project: https://github.com/goldhand/sw-precache-webpack-plugin#readme
|
||||
// Definitions by: JounQin <https://github.com/JounQin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Options as SwPrecacheOptions } from 'sw-precache';
|
||||
import { Plugin } from 'webpack';
|
||||
|
||||
// workaround to override parent types
|
||||
interface _Options extends SwPrecacheOptions {
|
||||
importScripts?: any;
|
||||
}
|
||||
|
||||
declare namespace SWPrecacheWebpackPlugin {
|
||||
interface Options extends _Options {
|
||||
filename?: string;
|
||||
filepath?: string;
|
||||
staticFileGlobsIgnorePatterns?: RegExp[];
|
||||
mergeStaticsConfig?: boolean;
|
||||
minify?: boolean;
|
||||
|
||||
// override sw-precache options
|
||||
importScripts?: Array<
|
||||
| string
|
||||
| {
|
||||
chunkName?: string;
|
||||
filename?: string;
|
||||
}
|
||||
>;
|
||||
}
|
||||
}
|
||||
|
||||
declare class SWPrecacheWebpackPlugin extends Plugin {
|
||||
constructor(options?: SWPrecacheWebpackPlugin.Options);
|
||||
}
|
||||
|
||||
export = SWPrecacheWebpackPlugin;
|
||||
@ -0,0 +1,36 @@
|
||||
import { Configuration } from 'webpack';
|
||||
import * as SwPrecacheWebpackPlugin from 'sw-precache-webpack-plugin';
|
||||
|
||||
let config: Configuration = {
|
||||
plugins: [new SwPrecacheWebpackPlugin()]
|
||||
};
|
||||
|
||||
config = {
|
||||
plugins: [
|
||||
new SwPrecacheWebpackPlugin({
|
||||
filename: ''
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
config = {
|
||||
plugins: [
|
||||
new SwPrecacheWebpackPlugin({
|
||||
cacheId: ''
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
config = {
|
||||
plugins: [
|
||||
new SwPrecacheWebpackPlugin({
|
||||
importScripts: [
|
||||
{
|
||||
chunkName: ''
|
||||
}
|
||||
]
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
export default config;
|
||||
23
types/sw-precache-webpack-plugin/tsconfig.json
Normal file
23
types/sw-precache-webpack-plugin/tsconfig.json
Normal file
@ -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",
|
||||
"sw-precache-webpack-plugin-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/sw-precache-webpack-plugin/tslint.json
Normal file
1
types/sw-precache-webpack-plugin/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user