From 44115af1cb209ec5d399ceb41cff5c11f70e52be Mon Sep 17 00:00:00 2001 From: Derek Sifford Date: Fri, 21 Jun 2019 04:15:40 -0400 Subject: [PATCH] [@wordpress/dependency-extraction-webpack-plugin] add new definitions (#36033) * [@wordpress/dependency-extraction-webpack-plugin] add new definitions * use more appropriate "export =" syntax --- .../index.d.ts | 20 ++++++++++++++++ .../tsconfig.json | 24 +++++++++++++++++++ .../tslint.json | 1 + ...endency-extraction-webpack-plugin-tests.ts | 23 ++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 types/wordpress__dependency-extraction-webpack-plugin/index.d.ts create mode 100644 types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json create mode 100644 types/wordpress__dependency-extraction-webpack-plugin/tslint.json create mode 100644 types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts diff --git a/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts b/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..319583a3d5 --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for @wordpress/dependency-extraction-webpack-plugin 1.0 +// Project: https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin/README.md +// Definitions by: Derek Sifford +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.5 + +import { Plugin } from "webpack"; + +interface Options { + useDefaults?: boolean; + injectPolyfill?: boolean; + requestToExternal?(request: string): string | string[] | void; + requestToHandle?(request: string): string | void; +} + +declare class DependencyExtractionWebpackPlugin extends Plugin { + constructor(options?: Options); +} + +export = DependencyExtractionWebpackPlugin; diff --git a/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json b/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..943b0ac3ac --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "paths": { + "@wordpress/dependency-extraction-webpack-plugin": [ + "wordpress__dependency-extraction-webpack-plugin" + ] + } + }, + "files": [ + "index.d.ts", + "wordpress__dependency-extraction-webpack-plugin-tests.ts" + ] +} diff --git a/types/wordpress__dependency-extraction-webpack-plugin/tslint.json b/types/wordpress__dependency-extraction-webpack-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts b/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts new file mode 100644 index 0000000000..48bccb227c --- /dev/null +++ b/types/wordpress__dependency-extraction-webpack-plugin/wordpress__dependency-extraction-webpack-plugin-tests.ts @@ -0,0 +1,23 @@ +import DependencyExtractionPlugin = require('@wordpress/dependency-extraction-webpack-plugin'); + +new DependencyExtractionPlugin(); + +new DependencyExtractionPlugin({ + useDefaults: false, +}); + +new DependencyExtractionPlugin({ + requestToExternal(request) { + if (request === "foo-bar") { + return "FooBar"; + } + if (request === "baz-qux") { + return ["baz", "qux"]; + } + }, + requestToHandle: request => { + if (request === "foo-bar") { + return "FooBar"; + } + } +});