Correct JSDoc typings for Webpack `cacheGroups` option?

Viewed 148

I have the following code in my webpack.config.js:

optimization: {
  splitChunks: {
    cacheGroups: buildWebpackCacheGroups(),
  },
},

In Webpack 4 I was able to annotate the return type of buildWebpackCacheGroups with JSDoc like this:

/**
 * @return {Record<string, webpack.Options.CacheGroupsOptions>}
 */
function buildWebpackCacheGroups() {

}

I'm now attempting to upgrade to Webpack 5, but webpack.Options.CacheGroupsOptions is no longer available as a type. So I tried the following:

/**
 * @return {Record<string, webpack.Configuration['optimization']['splitChunks']['cacheGroups']>}
 */
function buildWebpackCacheGroups() {

}

But it produces this error:

Property 'cacheGroups' does not exist on type 'false | OptimizationSplitChunksOptions'.

How can I solve this?

0 Answers
Related