Skip to content

Commit

Permalink
Add more precise JSDoc for Encore options
Browse files Browse the repository at this point in the history
This brings the list of supported options in the type definitions with
their type, which lets IDEs provide autocompletion for them.
  • Loading branch information
stof committed Apr 21, 2021
1 parent dfc6c80 commit e8ac09f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,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) {
Expand All @@ -498,6 +498,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.
*
Expand Down Expand Up @@ -558,7 +562,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) {
Expand Down Expand Up @@ -806,7 +810,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 = {}) {
Expand Down Expand Up @@ -938,7 +942,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 = {}) {
Expand Down Expand Up @@ -1092,7 +1096,7 @@ class Encore {
* Encore.enablePreactPreset({ preactCompat: true })
* ```
*
* @param {object} options
* @param {{preactCompat?: boolean}} options
* @returns {Encore}
*/
enablePreactPreset(options = {}) {
Expand Down Expand Up @@ -1224,7 +1228,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 = {}) {
Expand Down Expand Up @@ -1270,7 +1274,7 @@ class Encore {
* ```
*
* @param {string|object|(function(object): object|void)} eslintLoaderOptionsOrCallback
* @param {object} encoreOptions
* @param {{lintVue?: boolean}} encoreOptions
* @returns {Encore}
*/
enableEslintLoader(eslintLoaderOptionsOrCallback = () => {}, encoreOptions = {}) {
Expand Down Expand Up @@ -1399,7 +1403,7 @@ class Encore {
* which is overridden for both fonts and images. See configureImageRule()
* and configureFontRule() to control those filenames.
*
* @param {object} filenames
* @param {{js?: string, css?: string, images?: string, fonts?: string}} filenames
* @returns {Encore}
*/
configureFilenames(filenames) {
Expand Down

0 comments on commit e8ac09f

Please sign in to comment.