Skip to content

Commit 5088cca

Browse files
committed
Add more precise JSDoc for Encore options
This brings the list of supported options in the type definitions with their type, which lets IDEs provide autocompletion for them.
1 parent b8f8b74 commit 5088cca

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class Encore {
519519
* - `name` set to the value of the "name" parameter
520520
*
521521
* @param {string} name The chunk name (e.g. vendor to create a vendor.js)
522-
* @param {object} options Cache group option
522+
* @param {webpack.Options.CacheGroupsOptions&{node_modules?: string[]}} options Cache group option
523523
* @returns {Encore}
524524
*/
525525
addCacheGroup(name, options) {
@@ -528,6 +528,10 @@ class Encore {
528528
return this;
529529
}
530530

531+
/**
532+
* @typedef {{from: string, pattern?: RegExp|string, to?: string, includeSubdirectories?: boolean, context?: string}} CopyFilesOptions
533+
*/
534+
531535
/**
532536
* Copy files or folders to the build directory.
533537
*
@@ -588,7 +592,7 @@ class Encore {
588592
* - {string} context (default: path of the source directory)
589593
* The context to use as a root path when copying files.
590594
*
591-
* @param {object|Array} configs
595+
* @param {CopyFilesOptions|CopyFilesOptions[]} configs
592596
* @returns {Encore}
593597
*/
594598
copyFiles(configs) {
@@ -839,7 +843,7 @@ class Encore {
839843
* // https://www.npmjs.com/package/resolve-url-loader#options
840844
*
841845
* @param {OptionsCallback<object>} sassLoaderOptionsCallback
842-
* @param {object} encoreOptions
846+
* @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object}} encoreOptions
843847
* @returns {Encore}
844848
*/
845849
enableSassLoader(sassLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -971,7 +975,7 @@ class Encore {
971975
* if useBuiltIns isn't set to false.
972976
*
973977
* @param {OptionsCallback<object>|null} callback
974-
* @param {object} encoreOptions
978+
* @param {{exclude?: webpack.RuleSetCondition, includeNodeModules?: string[], useBuiltIns?: 'usage' | 'entry' | false, corejs?: number|string|object}} encoreOptions
975979
* @returns {Encore}
976980
*/
977981
configureBabel(callback, encoreOptions = {}) {
@@ -1125,7 +1129,7 @@ class Encore {
11251129
* Encore.enablePreactPreset({ preactCompat: true })
11261130
* ```
11271131
*
1128-
* @param {object} options
1132+
* @param {{preactCompat?: boolean}} options
11291133
* @returns {Encore}
11301134
*/
11311135
enablePreactPreset(options = {}) {
@@ -1257,7 +1261,7 @@ class Encore {
12571261
* in order to enable JSX usage in Vue components.
12581262
*
12591263
* @param {OptionsCallback<object>} vueLoaderOptionsCallback
1260-
* @param {object} encoreOptions
1264+
* @param {{useJsx?: boolean, version?: number, runtimeCompilerBuild?: boolean}} encoreOptions
12611265
* @returns {Encore}
12621266
*/
12631267
enableVueLoader(vueLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -1387,7 +1391,7 @@ class Encore {
13871391
* which is overridden for both fonts and images. See configureImageRule()
13881392
* and configureFontRule() to control those filenames.
13891393
*
1390-
* @param {object} filenames
1394+
* @param {{js?: string, css?: string, images?: string, fonts?: string}} filenames
13911395
* @returns {Encore}
13921396
*/
13931397
configureFilenames(filenames) {

0 commit comments

Comments
 (0)