diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index e8ef101feb..1470966296 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1665,7 +1665,7 @@ declare namespace webpack { } class DefinePlugin extends Plugin { - constructor(definitions: { [key: string]: DefinePlugin.CodeValuePrimitive}); + constructor(definitions: {[key: string]: DefinePlugin.CodeValueObject}); static runtimeValue( fn: ({ module }: { module: compilation.Module }) => DefinePlugin.CodeValuePrimitive, fileDependencies?: string[] @@ -1681,6 +1681,7 @@ declare namespace webpack { exec(parser: compilation.normalModuleFactory.Parser): CodeValuePrimitive; } type CodeValuePrimitive = string | number | boolean | RegExp | RuntimeValue | null | undefined; + type CodeValueObject = CodeValuePrimitive | {[key: string]: CodeValueObject}; } class DllPlugin extends Plugin { diff --git a/types/webpack/test/index.ts b/types/webpack/test/index.ts index 682c4d734d..520fbce4ff 100644 --- a/types/webpack/test/index.ts +++ b/types/webpack/test/index.ts @@ -446,6 +446,17 @@ plugin = new webpack.DefinePlugin({ BROWSER_SUPPORTS_HTML5: true, TWO: "1+1", "typeof window": JSON.stringify("object"), + OBJECT: { + foo: "bar", + bar: { + DEEP_RUNTIME: webpack.DefinePlugin.runtimeValue( + () => JSON.stringify("DEEP_RUUNTIME") + ), + foofoo: { + barbar: false + } + } + }, RUNTIME: webpack.DefinePlugin.runtimeValue( () => JSON.stringify("TEST_VALUE") )