Skip to content

Commit 7f87884

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 8769c15 commit 7f87884

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

index.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ class Encore {
514514
* * `name` set to the value of the "name" parameter
515515
*
516516
* @param {string} name The chunk name (e.g. vendor to create a vendor.js)
517-
* @param {object} options Cache group option
517+
* @param {webpack.Options.CacheGroupsOptions&{node_modules?: string[]}} options Cache group option
518518
* @returns {Encore}
519519
*/
520520
addCacheGroup(name, options) {
@@ -523,6 +523,10 @@ class Encore {
523523
return this;
524524
}
525525

526+
/**
527+
* @typedef {{from: string, pattern?: RegExp|string, to?: string, includeSubdirectories?: boolean, context?: string}} CopyFilesOptions
528+
*/
529+
526530
/**
527531
* Copy files or folders to the build directory.
528532
*
@@ -583,7 +587,7 @@ class Encore {
583587
* * {string} context (default: path of the source directory)
584588
* The context to use as a root path when copying files.
585589
*
586-
* @param {object|Array} configs
590+
* @param {CopyFilesOptions|CopyFilesOptions[]} configs
587591
* @returns {Encore}
588592
*/
589593
copyFiles(configs) {
@@ -830,7 +834,7 @@ class Encore {
830834
* // https://www.npmjs.com/package/resolve-url-loader#options
831835
*
832836
* @param {function(object): object|void} sassLoaderOptionsCallback
833-
* @param {object} encoreOptions
837+
* @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object}} encoreOptions
834838
* @returns {Encore}
835839
*/
836840
enableSassLoader(sassLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -962,7 +966,7 @@ class Encore {
962966
* if useBuiltIns isn't set to false.
963967
*
964968
* @param {(function(object): object|void)|null} callback
965-
* @param {object} encoreOptions
969+
* @param {{exclude?: webpack.RuleSetCondition, includeNodeModules?: string[], useBuiltIns?: 'usage' | 'entry' | false, corejs?: number|string|object}} encoreOptions
966970
* @returns {Encore}
967971
*/
968972
configureBabel(callback, encoreOptions = {}) {
@@ -1045,7 +1049,7 @@ class Encore {
10451049
* Encore.enablePreactPreset({ preactCompat: true })
10461050
* ```
10471051
*
1048-
* @param {object} options
1052+
* @param {{preactCompat?: boolean}} options
10491053
* @returns {Encore}
10501054
*/
10511055
enablePreactPreset(options = {}) {
@@ -1177,7 +1181,7 @@ class Encore {
11771181
* in order to enable JSX usage in Vue components.
11781182
*
11791183
* @param {function(object): object|void} vueLoaderOptionsCallback
1180-
* @param {object} encoreOptions
1184+
* @param {{useJsx?: boolean, version?: number, runtimeCompilerBuild?: boolean}} encoreOptions
11811185
* @returns {Encore}
11821186
*/
11831187
enableVueLoader(vueLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -1223,7 +1227,7 @@ class Encore {
12231227
* ```
12241228
*
12251229
* @param {string|object|(function(object): object|void)} eslintLoaderOptionsOrCallback
1226-
* @param {object} encoreOptions
1230+
* @param {{lintVue?: boolean}} encoreOptions
12271231
* @returns {Encore}
12281232
*/
12291233
enableEslintLoader(eslintLoaderOptionsOrCallback = () => {}, encoreOptions = {}) {
@@ -1365,7 +1369,7 @@ class Encore {
13651369
* make sure that your "js" and "css" filenames contain
13661370
* "[contenthash]".
13671371
*
1368-
* @param {object} filenames
1372+
* @param {{js?: string, css?: string, images?: string, fonts?: string}} filenames
13691373
* @returns {Encore}
13701374
*/
13711375
configureFilenames(filenames) {
@@ -1394,7 +1398,7 @@ class Encore {
13941398
* If a key (e.g. fonts) doesn't exists or contains a
13951399
* falsy value the file-loader will be used instead.
13961400
*
1397-
* @param {object} urlLoaderOptions
1401+
* @param {{images?: false|object, fonts?: false|object}} urlLoaderOptions
13981402
* @return {Encore}
13991403
*/
14001404
configureUrlLoader(urlLoaderOptions = {}) {

0 commit comments

Comments
 (0)