Skip to content

Commit f613e9a

Browse files
committed
chore(types): add basic type info for a few warning and errors
1 parent 0eeea0f commit f613e9a

4 files changed

+52
-8
lines changed

lib/AsyncDependencyToInitialChunkError.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@
66

77
const WebpackError = require("./WebpackError");
88

9-
module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
9+
/** @typedef {import("./Module")} Module */
10+
11+
class AsyncDependencyToInitialChunkError extends WebpackError {
12+
/**
13+
* Creates an instance of AsyncDependencyToInitialChunkError.
14+
* @param {string} chunkName Name of Chunk
15+
* @param {Module} module module tied to dependency
16+
* @param {TODO} loc location of dependency
17+
*/
1018
constructor(chunkName, module, loc) {
1119
super();
1220

@@ -18,4 +26,6 @@ module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
1826

1927
Error.captureStackTrace(this, this.constructor);
2028
}
21-
};
29+
}
30+
31+
module.exports = AsyncDependencyToInitialChunkError;

lib/CaseSensitiveModulesWarning.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77
const WebpackError = require("./WebpackError");
88

9-
module.exports = class CaseSensitiveModulesWarning extends WebpackError {
9+
/** @typedef {import("./Module")} Module */
10+
11+
class CaseSensitiveModulesWarning extends WebpackError {
12+
/**
13+
* Creates an instance of CaseSensitiveModulesWarning.
14+
* @param {Module[]} modules modules that were detected
15+
*/
1016
constructor(modules) {
1117
super();
1218

@@ -23,6 +29,11 @@ ${modulesList}`;
2329
Error.captureStackTrace(this, this.constructor);
2430
}
2531

32+
/**
33+
* @private
34+
* @param {Module[]} modules the modules to be sorted
35+
* @returns {Module[]} sorted version of original modules
36+
*/
2637
_sort(modules) {
2738
return modules.slice().sort((a, b) => {
2839
a = a.identifier();
@@ -36,6 +47,11 @@ ${modulesList}`;
3647
});
3748
}
3849

50+
/**
51+
* @private
52+
* @param {Module[]} modules each module from throw
53+
* @returns {string} each message from provided moduels
54+
*/
3955
_moduleMessages(modules) {
4056
return modules
4157
.map(m => {
@@ -50,4 +66,6 @@ ${modulesList}`;
5066
})
5167
.join("\n");
5268
}
53-
};
69+
}
70+
71+
module.exports = CaseSensitiveModulesWarning;

lib/ModuleDependencyError.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
const WebpackError = require("./WebpackError");
88
const formatLocation = require("./formatLocation");
99

10-
module.exports = class ModuleDependencyError extends WebpackError {
10+
/** @typedef {import("./Module")} Module */
11+
12+
class ModuleDependencyError extends WebpackError {
13+
/**
14+
* Creates an instance of ModuleDependencyError.
15+
* @param {Module} module module tied to dependency
16+
* @param {Error} err error thrown
17+
* @param {TODO} loc location of dependency
18+
*/
1119
constructor(module, err, loc) {
1220
super();
1321

@@ -22,4 +30,6 @@ module.exports = class ModuleDependencyError extends WebpackError {
2230

2331
Error.captureStackTrace(this, this.constructor);
2432
}
25-
};
33+
}
34+
35+
module.exports = ModuleDependencyError;

lib/WebpackError.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
*/
55
"use strict";
66

7-
module.exports = class WebpackError extends Error {
7+
class WebpackError extends Error {
8+
/**
9+
* Creates an instance of WebpackError.
10+
* @param {string=} message error message
11+
*/
812
constructor(message) {
913
super(message);
1014

@@ -16,4 +20,6 @@ module.exports = class WebpackError extends Error {
1620
inspect() {
1721
return this.stack + (this.details ? `\n${this.details}` : "");
1822
}
19-
};
23+
}
24+
25+
module.exports = WebpackError;

0 commit comments

Comments
 (0)