From e226101c5568726715d1069af4b7adf2bd3f62ff Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Fri, 16 Jun 2023 22:44:20 +0300 Subject: [PATCH] refactor(types): more --- lib/ContextModule.js | 2 +- lib/Entrypoint.js | 2 +- lib/dependencies/AMDDefineDependency.js | 38 +++++++++-- .../AMDDefineDependencyParserPlugin.js | 5 ++ lib/dependencies/CommonJsPlugin.js | 12 ++-- .../HarmonyExportDependencyParserPlugin.js | 2 + ...armonyExportImportedSpecifierDependency.js | 4 +- .../HarmonyImportSideEffectDependency.js | 3 +- .../HarmonyImportSpecifierDependency.js | 23 ++++--- lib/dependencies/ImportDependency.js | 8 ++- lib/dependencies/ImportEagerDependency.js | 2 +- lib/dependencies/ImportParserPlugin.js | 63 +++++++++++-------- lib/dependencies/ImportWeakDependency.js | 2 +- types.d.ts | 2 +- 14 files changed, 116 insertions(+), 52 deletions(-) diff --git a/lib/ContextModule.js b/lib/ContextModule.js index d99b1cec5..2100481f2 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -63,7 +63,7 @@ const makeSerializable = require("./util/makeSerializable"); * @property {RawChunkGroupOptions=} groupOptions * @property {string=} typePrefix * @property {string=} category - * @property {string[][]=} referencedExports exports referenced from modules (won't be mangled) + * @property {(string[][] | null)=} referencedExports exports referenced from modules (won't be mangled) * @property {string=} layer */ diff --git a/lib/Entrypoint.js b/lib/Entrypoint.js index e1ab20050..227939735 100644 --- a/lib/Entrypoint.js +++ b/lib/Entrypoint.js @@ -83,7 +83,7 @@ class Entrypoint extends ChunkGroup { * @returns {Chunk} chunk */ getEntrypointChunk() { - return this._entrypointChunk; + return /** @type {Chunk} */ (this._entrypointChunk); } /** diff --git a/lib/dependencies/AMDDefineDependency.js b/lib/dependencies/AMDDefineDependency.js index 5a26d9afc..7421243a0 100644 --- a/lib/dependencies/AMDDefineDependency.js +++ b/lib/dependencies/AMDDefineDependency.js @@ -180,6 +180,10 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends ( this.replace(dep, source, definition, content); } + /** + * @param {AMDDefineDependency} dependency dependency + * @returns {string} variable name + */ localModuleVar(dependency) { return ( dependency.localModule && @@ -188,6 +192,10 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends ( ); } + /** + * @param {AMDDefineDependency} dependency dependency + * @returns {string} branch + */ branch(dependency) { const localModuleVar = this.localModuleVar(dependency) ? "l" : ""; const arrayRange = dependency.arrayRange ? "a" : ""; @@ -196,6 +204,12 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends ( return localModuleVar + arrayRange + objectRange + functionRange; } + /** + * @param {AMDDefineDependency} dependency dependency + * @param {ReplaceSource} source source + * @param {string} definition definition + * @param {string} text text + */ replace(dependency, source, definition, text) { const localModuleVar = this.localModuleVar(dependency); if (localModuleVar) { @@ -216,18 +230,34 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends ( let current = dependency.range[0]; if (dependency.arrayRange) { - source.replace(current, dependency.arrayRange[0] - 1, texts.shift()); + source.replace( + current, + dependency.arrayRange[0] - 1, + /** @type {string} */ (texts.shift()) + ); current = dependency.arrayRange[1]; } if (dependency.objectRange) { - source.replace(current, dependency.objectRange[0] - 1, texts.shift()); + source.replace( + current, + dependency.objectRange[0] - 1, + /** @type {string} */ (texts.shift()) + ); current = dependency.objectRange[1]; } else if (dependency.functionRange) { - source.replace(current, dependency.functionRange[0] - 1, texts.shift()); + source.replace( + current, + dependency.functionRange[0] - 1, + /** @type {string} */ (texts.shift()) + ); current = dependency.functionRange[1]; } - source.replace(current, dependency.range[1] - 1, texts.shift()); + source.replace( + current, + dependency.range[1] - 1, + /** @type {string} */ (texts.shift()) + ); if (texts.length > 0) throw new Error("Implementation error"); } }; diff --git a/lib/dependencies/AMDDefineDependencyParserPlugin.js b/lib/dependencies/AMDDefineDependencyParserPlugin.js index 0b8edc93a..016fed698 100644 --- a/lib/dependencies/AMDDefineDependencyParserPlugin.js +++ b/lib/dependencies/AMDDefineDependencyParserPlugin.js @@ -16,8 +16,13 @@ const DynamicExports = require("./DynamicExports"); const LocalModuleDependency = require("./LocalModuleDependency"); const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers"); +/** @typedef {import("estree").CallExpression} CallExpression */ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ +/** + * @param {CallExpression} expr expression + * @returns {boolean} true if it's a bound function expression + */ const isBoundFunctionExpression = expr => { if (expr.type !== "CallExpression") return false; if (expr.callee.type !== "MemberExpression") return false; diff --git a/lib/dependencies/CommonJsPlugin.js b/lib/dependencies/CommonJsPlugin.js index a432edda3..b148b17b0 100644 --- a/lib/dependencies/CommonJsPlugin.js +++ b/lib/dependencies/CommonJsPlugin.js @@ -37,6 +37,8 @@ const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependen /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ /** @typedef {import("../Compilation")} Compilation */ /** @typedef {import("../Compiler")} Compiler */ +/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ +/** @typedef {import("../Module").BuildInfo} BuildInfo */ /** @typedef {import("../javascript/JavascriptParser")} Parser */ const PLUGIN_NAME = "CommonJsPlugin"; @@ -200,12 +202,13 @@ class CommonJsPlugin { parser.hooks.expression .for(RuntimeGlobals.moduleLoaded) .tap(PLUGIN_NAME, expr => { - parser.state.module.buildInfo.moduleConcatenationBailout = + /** @type {BuildInfo} */ + (parser.state.module.buildInfo).moduleConcatenationBailout = RuntimeGlobals.moduleLoaded; const dep = new RuntimeRequirementsDependency([ RuntimeGlobals.moduleLoaded ]); - dep.loc = expr.loc; + dep.loc = /** @type {DependencyLocation} */ (expr.loc); parser.state.module.addPresentationalDependency(dep); return true; }); @@ -213,12 +216,13 @@ class CommonJsPlugin { parser.hooks.expression .for(RuntimeGlobals.moduleId) .tap(PLUGIN_NAME, expr => { - parser.state.module.buildInfo.moduleConcatenationBailout = + /** @type {BuildInfo} */ + (parser.state.module.buildInfo).moduleConcatenationBailout = RuntimeGlobals.moduleId; const dep = new RuntimeRequirementsDependency([ RuntimeGlobals.moduleId ]); - dep.loc = expr.loc; + dep.loc = /** @type {DependencyLocation} */ (expr.loc); parser.state.module.addPresentationalDependency(dep); return true; }); diff --git a/lib/dependencies/HarmonyExportDependencyParserPlugin.js b/lib/dependencies/HarmonyExportDependencyParserPlugin.js index 35fba801a..bec73a104 100644 --- a/lib/dependencies/HarmonyExportDependencyParserPlugin.js +++ b/lib/dependencies/HarmonyExportDependencyParserPlugin.js @@ -18,6 +18,8 @@ const { } = require("./HarmonyImportDependencyParserPlugin"); const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency"); +/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ + const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency; module.exports = class HarmonyExportDependencyParserPlugin { diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 2feb97e65..ccab36f03 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -330,9 +330,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { * @param {string[]} ids the requested export name of the imported module * @param {string | null} name the export name of for this module * @param {Set} activeExports other named exports in the module - * @param {ReadonlyArray | Iterable} otherStarExports other star exports in the module before this import + * @param {ReadonlyArray | Iterable | null} otherStarExports other star exports in the module before this import * @param {number} exportPresenceMode mode of checking export names - * @param {HarmonyStarExportsList} allStarExports all star exports in the module + * @param {HarmonyStarExportsList | null} allStarExports all star exports in the module * @param {Assertions=} assertions import assertions */ constructor( diff --git a/lib/dependencies/HarmonyImportSideEffectDependency.js b/lib/dependencies/HarmonyImportSideEffectDependency.js index 5bd775266..21772da04 100644 --- a/lib/dependencies/HarmonyImportSideEffectDependency.js +++ b/lib/dependencies/HarmonyImportSideEffectDependency.js @@ -11,7 +11,6 @@ const HarmonyImportDependency = require("./HarmonyImportDependency"); /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ /** @typedef {import("../Dependency")} Dependency */ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ -/** @typedef {import("../InitFragment")} InitFragment */ /** @typedef {import("../Module")} Module */ /** @typedef {import("../ModuleGraph")} ModuleGraph */ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ @@ -74,7 +73,7 @@ HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDepend apply(dependency, source, templateContext) { const { moduleGraph, concatenationScope } = templateContext; if (concatenationScope) { - const module = moduleGraph.getModule(dependency); + const module = /** @type {Module} */ (moduleGraph.getModule(dependency)); if (concatenationScope.isModuleInScope(module)) { return; } diff --git a/lib/dependencies/HarmonyImportSpecifierDependency.js b/lib/dependencies/HarmonyImportSpecifierDependency.js index 3672afad6..32e9bc1bb 100644 --- a/lib/dependencies/HarmonyImportSpecifierDependency.js +++ b/lib/dependencies/HarmonyImportSpecifierDependency.js @@ -19,6 +19,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency"); /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ +/** @typedef {import("../Module")} Module */ +/** @typedef {import("../Module").BuildMeta} BuildMeta */ /** @typedef {import("../ModuleGraph")} ModuleGraph */ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ @@ -66,9 +68,9 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { this.directImport = undefined; this.shorthand = undefined; this.asiSafe = undefined; - /** @type {Set | boolean} */ + /** @type {Set | boolean | undefined} */ this.usedByExports = undefined; - /** @type {Set} */ + /** @type {Set | undefined} */ this.referencedPropertiesInDestructuring = undefined; } @@ -143,11 +145,14 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { let namespaceObjectAsContext = this.namespaceObjectAsContext; if (ids[0] === "default") { const selfModule = moduleGraph.getParentModule(this); - const importedModule = moduleGraph.getModule(this); + const importedModule = + /** @type {Module} */ + (moduleGraph.getModule(this)); switch ( importedModule.getExportsType( moduleGraph, - selfModule.buildMeta.strictHarmonyModule + /** @type {BuildMeta} */ + (selfModule.buildMeta).strictHarmonyModule ) ) { case "default-only": @@ -201,7 +206,10 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency { _getEffectiveExportPresenceLevel(moduleGraph) { if (this.exportPresenceMode !== ExportPresenceModes.AUTO) return this.exportPresenceMode; - return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule + const buildMeta = /** @type {BuildMeta} */ ( + moduleGraph.getParentModule(this).buildMeta + ); + return buildMeta.strictHarmonyModule ? ExportPresenceModes.ERROR : ExportPresenceModes.WARN; } @@ -362,9 +370,10 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen * @returns {string[]} generated code */ _trimIdsToThoseImported(ids, moduleGraph, dependency) { + /** @type {string[]} */ let trimmedIds = []; const exportsInfo = moduleGraph.getExportsInfo( - moduleGraph.getModule(dependency) + /** @type {Module} */ (moduleGraph.getModule(dependency)) ); let currentExportsInfo = /** @type {ExportsInfo=} */ exportsInfo; for (let i = 0; i < ids.length; i++) { @@ -437,7 +446,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen exportExpr = runtimeTemplate.exportFromImport({ moduleGraph, - module: moduleGraph.getModule(dep), + module: /** @type {Module} */ (moduleGraph.getModule(dep)), request: dep.request, exportName: ids, originModule: module, diff --git a/lib/dependencies/ImportDependency.js b/lib/dependencies/ImportDependency.js index 11d9a9773..a0eaffec3 100644 --- a/lib/dependencies/ImportDependency.js +++ b/lib/dependencies/ImportDependency.js @@ -13,6 +13,8 @@ const ModuleDependency = require("./ModuleDependency"); /** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */ /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ +/** @typedef {import("../Module")} Module */ +/** @typedef {import("../Module").BuildMeta} BuildMeta */ /** @typedef {import("../ModuleGraph")} ModuleGraph */ /** @typedef {import("../javascript/JavascriptParser").Range} Range */ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ @@ -23,7 +25,7 @@ class ImportDependency extends ModuleDependency { /** * @param {string} request the request * @param {Range} range expression range - * @param {string[][]=} referencedExports list of referenced exports + * @param {(string[][] | null)=} referencedExports list of referenced exports */ constructor(request, range, referencedExports) { super(request); @@ -96,9 +98,9 @@ ImportDependency.Template = class ImportDependencyTemplate extends ( const content = runtimeTemplate.moduleNamespacePromise({ chunkGraph, block: block, - module: moduleGraph.getModule(dep), + module: /** @type {Module} */ (moduleGraph.getModule(dep)), request: dep.request, - strict: module.buildMeta.strictHarmonyModule, + strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule, message: "import()", runtimeRequirements }); diff --git a/lib/dependencies/ImportEagerDependency.js b/lib/dependencies/ImportEagerDependency.js index ffb434ad9..806123e6b 100644 --- a/lib/dependencies/ImportEagerDependency.js +++ b/lib/dependencies/ImportEagerDependency.js @@ -21,7 +21,7 @@ class ImportEagerDependency extends ImportDependency { /** * @param {string} request the request * @param {Range} range expression range - * @param {string[][]=} referencedExports list of referenced exports + * @param {(string[][] | null)=} referencedExports list of referenced exports */ constructor(request, range, referencedExports) { super(request, range, referencedExports); diff --git a/lib/dependencies/ImportParserPlugin.js b/lib/dependencies/ImportParserPlugin.js index 7a2138533..afc6e700c 100644 --- a/lib/dependencies/ImportParserPlugin.js +++ b/lib/dependencies/ImportParserPlugin.js @@ -17,7 +17,10 @@ const ImportWeakDependency = require("./ImportWeakDependency"); /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */ /** @typedef {import("../ContextModule").ContextMode} ContextMode */ +/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ +/** @typedef {import("../Module").BuildMeta} BuildMeta */ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ +/** @typedef {import("../javascript/JavascriptParser").Range} Range */ class ImportParserPlugin { /** @@ -32,14 +35,18 @@ class ImportParserPlugin { * @returns {void} */ apply(parser) { + /** + * @template T + * @param {Iterable} enumerable enumerable + * @returns {T[][]} array of array + */ const exportsFromEnumerable = enumerable => Array.from(enumerable, e => [e]); parser.hooks.importCall.tap("ImportParserPlugin", expr => { const param = parser.evaluateExpression(expr.source); let chunkName = null; - /** @type {ContextMode} */ - let mode = this.options.dynamicImportMode; + let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode); let include = null; let exclude = null; /** @type {string[][] | null} */ @@ -68,7 +75,7 @@ class ImportParserPlugin { groupOptions.fetchPriority = dynamicImportFetchPriority; const { options: importOptions, errors: commentErrors } = - parser.parseCommentOptions(expr.range); + parser.parseCommentOptions(/** @type {Range} */ (expr.range)); if (commentErrors) { for (const e of commentErrors) { @@ -88,7 +95,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -103,7 +110,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -115,7 +122,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -131,7 +138,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackPrefetch\` expected true or a number, but received: ${importOptions.webpackPrefetch}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } @@ -145,7 +152,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackPreload\` expected true or a number, but received: ${importOptions.webpackPreload}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } @@ -160,7 +167,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackFetchPriority\` expected true or "low", "high" or "auto", but received: ${importOptions.webpackFetchPriority}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } @@ -173,7 +180,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackInclude\` expected a regular expression, but received: ${importOptions.webpackInclude}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -188,7 +195,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackExclude\` expected a regular expression, but received: ${importOptions.webpackExclude}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -200,7 +207,7 @@ class ImportParserPlugin { !( typeof importOptions.webpackExports === "string" || (Array.isArray(importOptions.webpackExports) && - importOptions.webpackExports.every( + /** @type {string[]} */ (importOptions.webpackExports).every( item => typeof item === "string" )) ) @@ -208,7 +215,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackExports\` expected a string or an array of strings, but received: ${importOptions.webpackExports}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } else { @@ -230,7 +237,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackMode\` expected 'lazy', 'lazy-once', 'eager' or 'weak', but received: ${mode}.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); mode = "lazy"; @@ -243,7 +250,7 @@ class ImportParserPlugin { parser.state.module.addWarning( new UnsupportedFeatureWarning( `\`webpackExports\` could not be used with destructuring assignment.`, - expr.loc + /** @type {DependencyLocation} */ (expr.loc) ) ); } @@ -253,15 +260,15 @@ class ImportParserPlugin { if (param.isString()) { if (mode === "eager") { const dep = new ImportEagerDependency( - param.string, - expr.range, + /** @type {string} */ (param.string), + /** @type {Range} */ (expr.range), exports ); parser.state.current.addDependency(dep); } else if (mode === "weak") { const dep = new ImportWeakDependency( - param.string, - expr.range, + /** @type {string} */ (param.string), + /** @type {Range} */ (expr.range), exports ); parser.state.current.addDependency(dep); @@ -271,11 +278,15 @@ class ImportParserPlugin { ...groupOptions, name: chunkName }, - expr.loc, + /** @type {DependencyLocation} */ (expr.loc), param.string ); - const dep = new ImportDependency(param.string, expr.range, exports); - dep.loc = expr.loc; + const dep = new ImportDependency( + /** @type {string} */ (param.string), + /** @type {Range} */ (expr.range), + exports + ); + dep.loc = /** @type {DependencyLocation} */ (expr.loc); depBlock.addDependency(dep); parser.state.current.addBlock(depBlock); } @@ -286,7 +297,7 @@ class ImportParserPlugin { } const dep = ContextDependencyHelpers.create( ImportContextDependency, - expr.range, + /** @type {Range} */ (expr.range), param, expr, this.options, @@ -296,7 +307,9 @@ class ImportParserPlugin { include, exclude, mode, - namespaceObject: parser.state.module.buildMeta.strictHarmonyModule + namespaceObject: /** @type {BuildMeta} */ ( + parser.state.module.buildMeta + ).strictHarmonyModule ? "strict" : true, typePrefix: "import()", @@ -306,7 +319,7 @@ class ImportParserPlugin { parser ); if (!dep) return; - dep.loc = expr.loc; + dep.loc = /** @type {DependencyLocation} */ (expr.loc); dep.optional = !!parser.scope.inTry; parser.state.current.addDependency(dep); return true; diff --git a/lib/dependencies/ImportWeakDependency.js b/lib/dependencies/ImportWeakDependency.js index 3b78d8586..00f347202 100644 --- a/lib/dependencies/ImportWeakDependency.js +++ b/lib/dependencies/ImportWeakDependency.js @@ -21,7 +21,7 @@ class ImportWeakDependency extends ImportDependency { /** * @param {string} request the request * @param {Range} range expression range - * @param {string[][]=} referencedExports list of referenced exports + * @param {(string[][] | null)=} referencedExports list of referenced exports */ constructor(request, range, referencedExports) { super(request, range, referencedExports); diff --git a/types.d.ts b/types.d.ts index 8e57cefb3..726cc6226 100644 --- a/types.d.ts +++ b/types.d.ts @@ -2840,7 +2840,7 @@ declare interface ContextModuleOptions { /** * exports referenced from modules (won't be mangled) */ - referencedExports?: string[][]; + referencedExports?: null | string[][]; layer?: string; resource: string | false | string[]; resourceQuery?: string;