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:
JounQin 2018-05-08 00:18:22 +08:00 committed by Andy
parent b14a53f475
commit e8849415f2
4 changed files with 98 additions and 0 deletions

View 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;

View File

@ -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;

View 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"
]
}

View File

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