refactor(ts): strictNullChecks and improvements for Module subclasses and compilation queues
This commit is contained in:
parent
10282ea206
commit
9451b7c96d
|
@ -31,6 +31,17 @@ declare module 'chrome-trace-event' {
|
|||
}
|
||||
}
|
||||
|
||||
interface LocationPosition {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
|
||||
interface Location {
|
||||
start: LocationPosition,
|
||||
end: LocationPosition,
|
||||
index: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Global variable declarations
|
||||
* @todo Once this issue is resolved, remove these globals and add JSDoc onsite instead
|
||||
|
|
|
@ -247,8 +247,8 @@ class Compilation extends Tapable {
|
|||
this._modules = new Map();
|
||||
this.cache = null;
|
||||
this.records = null;
|
||||
this.nextFreeModuleIndex = undefined;
|
||||
this.nextFreeModuleIndex2 = undefined;
|
||||
this.nextFreeModuleIndex = 0;
|
||||
this.nextFreeModuleIndex2 = 0;
|
||||
this.additionalChunkAssets = [];
|
||||
this.assets = {};
|
||||
this.errors = [];
|
||||
|
@ -1104,6 +1104,8 @@ class Compilation extends Tapable {
|
|||
};
|
||||
|
||||
while (queue.length) {
|
||||
//@ts-ignore
|
||||
//https://github.com/Microsoft/TypeScript/issues/23403
|
||||
queue.pop()();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ class ContextModule extends Module {
|
|||
throw new Error("options.mode is a required option");
|
||||
|
||||
this._identifier = this._createIdentifier();
|
||||
|
||||
// Build meta
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
updateCacheModule(module) {
|
||||
|
|
|
@ -22,6 +22,7 @@ class DelegatedModule extends Module {
|
|||
this.userRequest = userRequest;
|
||||
this.originalRequest = originalRequest;
|
||||
this.delegateData = data;
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
libIdent(options) {
|
||||
|
|
|
@ -11,6 +11,7 @@ class DependenciesBlock {
|
|||
this.dependencies = [];
|
||||
this.blocks = [];
|
||||
this.variables = [];
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
addBlock(block) {
|
||||
|
|
|
@ -15,6 +15,7 @@ class DllModule extends Module {
|
|||
this.dependencies = dependencies;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
identifier() {
|
||||
|
|
|
@ -18,6 +18,7 @@ class ExternalModule extends Module {
|
|||
this.externalType = type;
|
||||
this.userRequest = userRequest;
|
||||
this.external = true;
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
libIdent() {
|
||||
|
|
|
@ -88,7 +88,7 @@ module.exports = function() {
|
|||
_declinedDependencies: {},
|
||||
_selfAccepted: false,
|
||||
_selfDeclined: false,
|
||||
_disposeHandlers: [],
|
||||
/** @type {Function[]} */ _disposeHandlers: [],
|
||||
_main: hotCurrentChildModule !== moduleId,
|
||||
|
||||
// Module API
|
||||
|
@ -286,7 +286,10 @@ module.exports = function() {
|
|||
});
|
||||
while (queue.length > 0) {
|
||||
var queueItem = queue.pop();
|
||||
//@ts-ignore
|
||||
//https://github.com/Microsoft/TypeScript/issues/23403
|
||||
var moduleId = queueItem.id;
|
||||
//@ts-ignore
|
||||
var chain = queueItem.chain;
|
||||
module = installedModules[moduleId];
|
||||
if (!module || module.hot._selfAccepted) continue;
|
||||
|
|
|
@ -36,15 +36,14 @@ class Module extends DependenciesBlock {
|
|||
this.type = type;
|
||||
/** @type {string} */
|
||||
this.context = context;
|
||||
|
||||
// Unique Id
|
||||
/** @type {number} */
|
||||
this.debugId = debugId++;
|
||||
|
||||
// Hash
|
||||
/** @type {string} */
|
||||
/** @type {string=} */
|
||||
this.hash = undefined;
|
||||
/** @type {string} */
|
||||
/** @type {string=} */
|
||||
this.renderedHash = undefined;
|
||||
|
||||
// Info from Factory
|
||||
|
@ -62,6 +61,8 @@ class Module extends DependenciesBlock {
|
|||
this.buildMeta = undefined;
|
||||
/** @type {object} */
|
||||
this.buildInfo = undefined;
|
||||
/** @type {boolean} */
|
||||
this.built = false;
|
||||
|
||||
// Graph (per Compilation)
|
||||
/** @type {ModuleReason[]} */
|
||||
|
@ -70,16 +71,16 @@ class Module extends DependenciesBlock {
|
|||
this._chunks = new SortableSet(undefined, sortById);
|
||||
|
||||
// Info from Compilation (per Compilation)
|
||||
/** @type {number | string} */
|
||||
this.id = null;
|
||||
/** @type {number} */
|
||||
this.index = null;
|
||||
/** @type {number} */
|
||||
this.index2 = null;
|
||||
/** @type {number} */
|
||||
this.depth = null;
|
||||
/** @type {Module} */
|
||||
this.issuer = null;
|
||||
/** @type {(number | string)=} */
|
||||
this.id = undefined;
|
||||
/** @type {number=} */
|
||||
this.index = undefined;
|
||||
/** @type {number=} */
|
||||
this.index2 = undefined;
|
||||
/** @type {number=} */
|
||||
this.depth = undefined;
|
||||
/** @type {Module=} */
|
||||
this.issuer = undefined;
|
||||
/** @type {undefined | object} */
|
||||
this.profile = undefined;
|
||||
/** @type {boolean} */
|
||||
|
@ -88,10 +89,10 @@ class Module extends DependenciesBlock {
|
|||
this.built = false;
|
||||
|
||||
// Info from Optimization (per Compilation)
|
||||
/** @type {null | boolean} */
|
||||
this.used = null;
|
||||
/** @type {false | true | string[]} */
|
||||
this.usedExports = null;
|
||||
/** @type {boolean=} */
|
||||
this.used = undefined;
|
||||
/** @type {(false | true | string[])=} */
|
||||
this.usedExports = undefined;
|
||||
/** @type {(string | OptimizationBailoutFunction)[]} */
|
||||
this.optimizationBailout = [];
|
||||
|
||||
|
@ -119,26 +120,26 @@ class Module extends DependenciesBlock {
|
|||
this._rewriteChunkInReasons = undefined;
|
||||
this._chunks.clear();
|
||||
|
||||
this.id = null;
|
||||
this.index = null;
|
||||
this.index2 = null;
|
||||
this.depth = null;
|
||||
this.issuer = null;
|
||||
this.id = undefined;
|
||||
this.index = undefined;
|
||||
this.index2 = undefined;
|
||||
this.depth = undefined;
|
||||
this.issuer = undefined;
|
||||
this.profile = undefined;
|
||||
this.prefetched = false;
|
||||
this.built = false;
|
||||
|
||||
this.used = null;
|
||||
this.usedExports = null;
|
||||
this.used = undefined;
|
||||
this.usedExports = undefined;
|
||||
this.optimizationBailout.length = 0;
|
||||
super.disconnect();
|
||||
}
|
||||
|
||||
unseal() {
|
||||
this.id = null;
|
||||
this.index = null;
|
||||
this.index2 = null;
|
||||
this.depth = null;
|
||||
this.id = undefined;
|
||||
this.index = undefined;
|
||||
this.index2 = undefined;
|
||||
this.depth = undefined;
|
||||
this._chunks.clear();
|
||||
super.unseal();
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ class MultiModule extends Module {
|
|||
this._identifier = `multi ${this.dependencies
|
||||
.map(d => d.request)
|
||||
.join(" ")}`;
|
||||
this.built = false;
|
||||
}
|
||||
|
||||
identifier() {
|
||||
|
|
|
@ -92,6 +92,7 @@ class NormalModule extends Module {
|
|||
this.buildTimestamp = undefined;
|
||||
this._cachedSource = undefined;
|
||||
this._cachedSourceHash = undefined;
|
||||
this.built = false;
|
||||
|
||||
// Options for the NormalModule set by plugins
|
||||
// TODO refactor this -> options object filled from Factory
|
||||
|
|
|
@ -32,5 +32,7 @@ module.exports = (a, b) => {
|
|||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
/* Strict Type-Checking Options */
|
||||
"strict": false, /* Enable all strict type-checking options. */
|
||||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
// "strictNullChecks": true, /* Enable strict null checks. */
|
||||
"strictNullChecks": true, /* Enable strict null checks. */
|
||||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
||||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
||||
|
|
Loading…
Reference in New Issue