From 64518339d71c70c03e52d1d8c8a8891268839aa2 Mon Sep 17 00:00:00 2001 From: Ori Date: Tue, 12 Mar 2024 23:18:18 +0200 Subject: [PATCH] refactor: add type annotations --- src/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index f304fd90..5d81e36b 100644 --- a/src/index.js +++ b/src/index.js @@ -845,7 +845,12 @@ class MiniCssExtractPlugin { return obj; }; - // @ts-ignore + + /** + * @param {Chunk} chunk chunk + * @param {ChunkGraph} chunkGraph chunk graph + * @returns {boolean} true, when the chunk has css + */ function chunkHasCss(chunk, chunkGraph) { // this function replace: // const chunkHasCss = require("webpack/lib/css/CssModulesPlugin").chunkHasCss; @@ -884,13 +889,12 @@ class MiniCssExtractPlugin { /** @type {Chunk} */ (chunk), /** @type {Compilation} */ (this.compilation) ); - const globalObject = runtimeTemplate.globalObject; + const { globalObject } = runtimeTemplate; const { linkPreload, linkPrefetch } = JsonpChunkLoadingRuntimeModule.getCompilationHooks(compilation); - const conditionMap = chunkGraph.getChunkConditionMap( - chunk, - chunkHasCss - ); + const conditionMap = /** @type {ChunkGraph} */ ( + chunkGraph + ).getChunkConditionMap(/** @type {Chunk} */ (chunk), chunkHasCss); const hasCssMatcher = compileBooleanMatcher(conditionMap); const withLoading =