Skip to content

Commit 17ce5fd

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 5abbc72 commit 17ce5fd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

index.js

Lines changed: 13 additions & 9 deletions
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) {
@@ -831,7 +835,7 @@ class Encore {
831835
* // https://www.npmjs.com/package/resolve-url-loader#options
832836
*
833837
* @param {function(object): object|void} sassLoaderOptionsCallback
834-
* @param {object} encoreOptions
838+
* @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object}} encoreOptions
835839
* @returns {Encore}
836840
*/
837841
enableSassLoader(sassLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -963,7 +967,7 @@ class Encore {
963967
* if useBuiltIns isn't set to false.
964968
*
965969
* @param {(function(object): object|void)|null} callback
966-
* @param {object} encoreOptions
970+
* @param {{exclude?: webpack.RuleSetCondition, includeNodeModules?: string[], useBuiltIns?: 'usage' | 'entry' | false, corejs?: number|string|object}} encoreOptions
967971
* @returns {Encore}
968972
*/
969973
configureBabel(callback, encoreOptions = {}) {
@@ -1058,7 +1062,7 @@ class Encore {
10581062
* Encore.enablePreactPreset({ preactCompat: true })
10591063
* ```
10601064
*
1061-
* @param {object} options
1065+
* @param {{preactCompat?: boolean}} options
10621066
* @returns {Encore}
10631067
*/
10641068
enablePreactPreset(options = {}) {
@@ -1190,7 +1194,7 @@ class Encore {
11901194
* in order to enable JSX usage in Vue components.
11911195
*
11921196
* @param {function(object): object|void} vueLoaderOptionsCallback
1193-
* @param {object} encoreOptions
1197+
* @param {{useJsx?: boolean, version?: number, runtimeCompilerBuild?: boolean}} encoreOptions
11941198
* @returns {Encore}
11951199
*/
11961200
enableVueLoader(vueLoaderOptionsCallback = () => {}, encoreOptions = {}) {
@@ -1236,7 +1240,7 @@ class Encore {
12361240
* ```
12371241
*
12381242
* @param {string|object|(function(object): object|void)} eslintLoaderOptionsOrCallback
1239-
* @param {object} encoreOptions
1243+
* @param {{lintVue?: boolean}} encoreOptions
12401244
* @returns {Encore}
12411245
*/
12421246
enableEslintLoader(eslintLoaderOptionsOrCallback = () => {}, encoreOptions = {}) {
@@ -1378,7 +1382,7 @@ class Encore {
13781382
* make sure that your "js" and "css" filenames contain
13791383
* "[contenthash]".
13801384
*
1381-
* @param {object} filenames
1385+
* @param {{js?: string, css?: string, images?: string, fonts?: string}} filenames
13821386
* @returns {Encore}
13831387
*/
13841388
configureFilenames(filenames) {
@@ -1407,7 +1411,7 @@ class Encore {
14071411
* If a key (e.g. fonts) doesn't exists or contains a
14081412
* falsy value the file-loader will be used instead.
14091413
*
1410-
* @param {object} urlLoaderOptions
1414+
* @param {{images?: false|object, fonts?: false|object}} urlLoaderOptions
14111415
* @return {Encore}
14121416
*/
14131417
configureUrlLoader(urlLoaderOptions = {}) {

0 commit comments

Comments
 (0)