diff --git a/types/react-loadable/index.d.ts b/types/react-loadable/index.d.ts index d2229d4bf6..beeb569d4c 100644 --- a/types/react-loadable/index.d.ts +++ b/types/react-loadable/index.d.ts @@ -4,6 +4,7 @@ // Oden S. // Ian Ker-Seymer // Tomek Łaziuk +// Ian Mobley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/react-loadable/test/webpack.ts b/types/react-loadable/test/webpack.ts new file mode 100644 index 0000000000..ecfa79cd53 --- /dev/null +++ b/types/react-loadable/test/webpack.ts @@ -0,0 +1,25 @@ +import webpack = require('webpack'); +import Loadable = require('react-loadable/webpack'); + +const config: webpack.Configuration = { + plugins: [ + new Loadable.ReactLoadablePlugin(), + new Loadable.ReactLoadablePlugin({ + filename: 'react-loadable.json' + }) + ] +}; + +const manifest = { + react: [ + { + id: 0, + name: './node_modules/react/index.js', + file: 'main.js' + } + ] +}; + +const manifestIds = ['react']; + +const bundles = Loadable.getBundles(manifest, manifestIds); diff --git a/types/react-loadable/tsconfig.json b/types/react-loadable/tsconfig.json index 9d46ae0de9..a2ad20875b 100644 --- a/types/react-loadable/tsconfig.json +++ b/types/react-loadable/tsconfig.json @@ -19,8 +19,10 @@ }, "files": [ "index.d.ts", + "webpack.d.ts", "test/index.tsx", + "test/webpack.ts", "test/imports/no-default.tsx", "test/imports/with-default.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-loadable/webpack.d.ts b/types/react-loadable/webpack.d.ts new file mode 100644 index 0000000000..54732527d8 --- /dev/null +++ b/types/react-loadable/webpack.d.ts @@ -0,0 +1,30 @@ +import webpack = require("webpack"); + +declare namespace LoadableExport { + interface Options { + filename: string; + } + + class ReactLoadablePlugin extends webpack.Plugin { + constructor(opts?: Options); + } + + interface Bundle { + id: number; + name: string; + file: string; + } + + interface Manifest { + [moduleId: string]: Bundle[]; + } + + function getBundles(manifest: Manifest, moduleIds: string[]): Bundle[]; +} + +declare const exports: { + getBundles: typeof LoadableExport.getBundles; + ReactLoadablePlugin: typeof LoadableExport.ReactLoadablePlugin; +}; + +export = exports;