add types to Module

This commit is contained in:
Tobias Koppers 2018-04-12 09:18:53 +02:00
parent 2adf5c2b0d
commit 8de3b9bd22
1 changed files with 32 additions and 0 deletions

View File

@ -11,6 +11,10 @@ const ModuleReason = require("./ModuleReason");
const SortableSet = require("./util/SortableSet"); const SortableSet = require("./util/SortableSet");
const Template = require("./Template"); const Template = require("./Template");
/** @typedef {typeof import("./Chunk")} Chunk */
/** @typedef {typeof import("./RequestShortener")} RequestShortener */
const EMPTY_RESOLVE_OPTIONS = {}; const EMPTY_RESOLVE_OPTIONS = {};
let debugId = 1000; let debugId = 1000;
@ -23,51 +27,79 @@ const sortByDebugId = (a, b) => {
return a.debugId - b.debugId; return a.debugId - b.debugId;
}; };
/** @typedef {(requestShortener: RequestShortener) => string} OptimizationBailoutFunction */
class Module extends DependenciesBlock { class Module extends DependenciesBlock {
constructor(type, context = null) { constructor(type, context = null) {
super(); super();
/** @type {string} */
this.type = type; this.type = type;
/** @type {string} */
this.context = context; this.context = context;
// Unique Id // Unique Id
/** @type {number} */
this.debugId = debugId++; this.debugId = debugId++;
// Hash // Hash
/** @type {string} */
this.hash = undefined; this.hash = undefined;
/** @type {string} */
this.renderedHash = undefined; this.renderedHash = undefined;
// Info from Factory // Info from Factory
/** @type {object} */
this.resolveOptions = EMPTY_RESOLVE_OPTIONS; this.resolveOptions = EMPTY_RESOLVE_OPTIONS;
/** @type {object} */
this.factoryMeta = {}; this.factoryMeta = {};
// Info from Build // Info from Build
/** @type {Error[]} */
this.warnings = []; this.warnings = [];
/** @type {Error[]} */
this.errors = []; this.errors = [];
/** @type {object} */
this.buildMeta = undefined; this.buildMeta = undefined;
/** @type {object} */
this.buildInfo = undefined; this.buildInfo = undefined;
// Graph (per Compilation) // Graph (per Compilation)
/** @type {ModuleReason[]} */
this.reasons = []; this.reasons = [];
/** @type {SortableSet} */
this._chunks = new SortableSet(undefined, sortById); this._chunks = new SortableSet(undefined, sortById);
// Info from Compilation (per Compilation) // Info from Compilation (per Compilation)
/** @type {number | string} */
this.id = null; this.id = null;
/** @type {number} */
this.index = null; this.index = null;
/** @type {number} */
this.index2 = null; this.index2 = null;
/** @type {number} */
this.depth = null; this.depth = null;
/** @type {Module} */
this.issuer = null; this.issuer = null;
/** @type {undefined | object} */
this.profile = undefined; this.profile = undefined;
/** @type {boolean} */
this.prefetched = false; this.prefetched = false;
/** @type {boolean} */
this.built = false; this.built = false;
// Info from Optimization (per Compilation) // Info from Optimization (per Compilation)
/** @type {null | boolean} */
this.used = null; this.used = null;
/** @type {false | true | string[]} */
this.usedExports = null; this.usedExports = null;
/** @type {(string | OptimizationBailoutFunction)[]} */
this.optimizationBailout = []; this.optimizationBailout = [];
// delayed operations // delayed operations
/** @type {undefined | {oldChunk: Chunk, newChunks: Chunk[]}[] } */
this._rewriteChunkInReasons = undefined; this._rewriteChunkInReasons = undefined;
/** @type {boolean} */
this.useSourceMap = false; this.useSourceMap = false;
} }