Skip to content

Commit ee6097c

Browse files
committed
Add more precise types for arguments forwarded to webpack
webpack provides type definitions for their whole API, so we can reference their type rather than specifying a generic "object" type. Referencing the webpack types was already done for the returned configuration.
1 parent bd2e616 commit ee6097c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class Encore {
326326
* Encore.addPlugin(new MyWebpackPlugin(), PluginPriorities.DefinePlugin);
327327
* ```
328328
*
329-
* @param {object} plugin
329+
* @param {webpack.WebpackPluginInstance} plugin
330330
* @param {number} priority
331331
* @returns {Encore}
332332
*/
@@ -339,7 +339,7 @@ class Encore {
339339
/**
340340
* Adds a custom loader config
341341
*
342-
* @param {object} loader The loader config object
342+
* @param {webpack.RuleSetRule} loader The loader config object
343343
* @returns {Encore}
344344
*/
345345
addLoader(loader) {
@@ -351,7 +351,7 @@ class Encore {
351351
/**
352352
* Alias to addLoader
353353
*
354-
* @param {object} rule
354+
* @param {webpack.RuleSetRule} rule
355355
* @returns {Encore}
356356
*/
357357
addRule(rule) {
@@ -414,7 +414,7 @@ class Encore {
414414
* ]);
415415
* ```
416416
*
417-
* @param {*} externals
417+
* @param {webpack.Externals} externals
418418
* @returns {Encore}
419419
*/
420420
addExternals(externals) {
@@ -931,7 +931,7 @@ class Encore {
931931
* ```
932932
*
933933
* Supported options:
934-
* - {Condition} exclude (default=/(node_modules|bower_components)/)
934+
* - {webpack.RuleSetCondition} exclude (default=/(node_modules|bower_components)/)
935935
* A Webpack Condition passed to the JS/JSX rule that
936936
* determines which files and folders should not be
937937
* processed by Babel (https://webpack.js.org/configuration/module/#condition).

lib/WebpackConfig.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
* @import RuntimeConfig from './config/RuntimeConfig'
1414
*/
1515

16+
/**
17+
* @import webpack from 'webpack'
18+
*/
19+
1620
const path = require('path');
1721
const fs = require('fs');
1822
const crypto = require('crypto');
@@ -356,6 +360,9 @@ class WebpackConfig {
356360
Object.assign(this.aliases, aliases);
357361
}
358362

363+
/**
364+
* @param {webpack.Externals} externals
365+
*/
359366
addExternals(externals = []) {
360367
if (!Array.isArray(externals)) {
361368
externals = [externals];

0 commit comments

Comments
 (0)