From 7f87884c1c13c9d92230a67b10edefa0b20857a2 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 4 Aug 2020 01:15:42 +0200 Subject: [PATCH] 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. --- index.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 9b37b3d1..a26a35ca 100644 --- a/index.js +++ b/index.js @@ -514,7 +514,7 @@ class Encore { * * `name` set to the value of the "name" parameter * * @param {string} name The chunk name (e.g. vendor to create a vendor.js) - * @param {object} options Cache group option + * @param {webpack.Options.CacheGroupsOptions&{node_modules?: string[]}} options Cache group option * @returns {Encore} */ addCacheGroup(name, options) { @@ -523,6 +523,10 @@ class Encore { return this; } + /** + * @typedef {{from: string, pattern?: RegExp|string, to?: string, includeSubdirectories?: boolean, context?: string}} CopyFilesOptions + */ + /** * Copy files or folders to the build directory. * @@ -583,7 +587,7 @@ class Encore { * * {string} context (default: path of the source directory) * The context to use as a root path when copying files. * - * @param {object|Array} configs + * @param {CopyFilesOptions|CopyFilesOptions[]} configs * @returns {Encore} */ copyFiles(configs) { @@ -830,7 +834,7 @@ class Encore { * // https://www.npmjs.com/package/resolve-url-loader#options * * @param {function(object): object|void} sassLoaderOptionsCallback - * @param {object} encoreOptions + * @param {{resolveUrlLoader?: boolean, resolveUrlLoaderOptions?: object}} encoreOptions * @returns {Encore} */ enableSassLoader(sassLoaderOptionsCallback = () => {}, encoreOptions = {}) { @@ -962,7 +966,7 @@ class Encore { * if useBuiltIns isn't set to false. * * @param {(function(object): object|void)|null} callback - * @param {object} encoreOptions + * @param {{exclude?: webpack.RuleSetCondition, includeNodeModules?: string[], useBuiltIns?: 'usage' | 'entry' | false, corejs?: number|string|object}} encoreOptions * @returns {Encore} */ configureBabel(callback, encoreOptions = {}) { @@ -1045,7 +1049,7 @@ class Encore { * Encore.enablePreactPreset({ preactCompat: true }) * ``` * - * @param {object} options + * @param {{preactCompat?: boolean}} options * @returns {Encore} */ enablePreactPreset(options = {}) { @@ -1177,7 +1181,7 @@ class Encore { * in order to enable JSX usage in Vue components. * * @param {function(object): object|void} vueLoaderOptionsCallback - * @param {object} encoreOptions + * @param {{useJsx?: boolean, version?: number, runtimeCompilerBuild?: boolean}} encoreOptions * @returns {Encore} */ enableVueLoader(vueLoaderOptionsCallback = () => {}, encoreOptions = {}) { @@ -1223,7 +1227,7 @@ class Encore { * ``` * * @param {string|object|(function(object): object|void)} eslintLoaderOptionsOrCallback - * @param {object} encoreOptions + * @param {{lintVue?: boolean}} encoreOptions * @returns {Encore} */ enableEslintLoader(eslintLoaderOptionsOrCallback = () => {}, encoreOptions = {}) { @@ -1365,7 +1369,7 @@ class Encore { * make sure that your "js" and "css" filenames contain * "[contenthash]". * - * @param {object} filenames + * @param {{js?: string, css?: string, images?: string, fonts?: string}} filenames * @returns {Encore} */ configureFilenames(filenames) { @@ -1394,7 +1398,7 @@ class Encore { * If a key (e.g. fonts) doesn't exists or contains a * falsy value the file-loader will be used instead. * - * @param {object} urlLoaderOptions + * @param {{images?: false|object, fonts?: false|object}} urlLoaderOptions * @return {Encore} */ configureUrlLoader(urlLoaderOptions = {}) {