diff --git a/types/sw-precache-webpack-plugin/index.d.ts b/types/sw-precache-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..3378e55f08 --- /dev/null +++ b/types/sw-precache-webpack-plugin/index.d.ts @@ -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 +// 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; diff --git a/types/sw-precache-webpack-plugin/sw-precache-webpack-plugin-tests.ts b/types/sw-precache-webpack-plugin/sw-precache-webpack-plugin-tests.ts new file mode 100644 index 0000000000..5cc7fd7c38 --- /dev/null +++ b/types/sw-precache-webpack-plugin/sw-precache-webpack-plugin-tests.ts @@ -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; diff --git a/types/sw-precache-webpack-plugin/tsconfig.json b/types/sw-precache-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..f26bc80766 --- /dev/null +++ b/types/sw-precache-webpack-plugin/tsconfig.json @@ -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" + ] +} diff --git a/types/sw-precache-webpack-plugin/tslint.json b/types/sw-precache-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sw-precache-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }