Skip to content

Commit

Permalink
fix: types for the parallel option (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Sep 9, 2021
1 parent 210a5a0 commit 1e14230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,17 @@ import { minify as minimize } from "./minify";
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
*/

/**
* @typedef {undefined | boolean | number} Parallel
*/

/**
* @typedef {Object} BasePluginOptions
* @property {Rules} [test]
* @property {Rules} [include]
* @property {Rules} [exclude]
* @property {ExtractCommentsOptions} [extractComments]
* @property {boolean} [parallel]
* @property {Parallel} [parallel]
*/

/**
Expand Down Expand Up @@ -307,7 +311,7 @@ class TerserPlugin {

/**
* @private
* @param {boolean | undefined} parallel
* @param {Parallel} parallel
* @returns {number}
*/
static getAvailableNumberOfCores(parallel) {
Expand Down
12 changes: 8 additions & 4 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ export type MinimizeFunctionHelpers = {
};
export type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
MinimizeFunctionHelpers;
export type Parallel = undefined | boolean | number;
export type BasePluginOptions = {
test?: Rules | undefined;
include?: Rules | undefined;
exclude?: Rules | undefined;
extractComments?: ExtractCommentsOptions | undefined;
parallel?: boolean | undefined;
parallel?: Parallel;
};
export type InferDefaultType<T> = T extends infer U
? U
Expand Down Expand Up @@ -188,13 +189,16 @@ export type DefinedDefaultMinimizerAndOptions<T> =
* @template T
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
*/
/**
* @typedef {undefined | boolean | number} Parallel
*/
/**
* @typedef {Object} BasePluginOptions
* @property {Rules} [test]
* @property {Rules} [include]
* @property {Rules} [exclude]
* @property {ExtractCommentsOptions} [extractComments]
* @property {boolean} [parallel]
* @property {Parallel} [parallel]
*/
/**
* @template T
Expand Down Expand Up @@ -232,7 +236,7 @@ declare class TerserPlugin<T = TerserOptions> {
private static buildError;
/**
* @private
* @param {boolean | undefined} parallel
* @param {Parallel} parallel
* @returns {number}
*/
private static getAvailableNumberOfCores;
Expand All @@ -253,7 +257,7 @@ declare class TerserPlugin<T = TerserOptions> {
options: {
test: Rules;
extractComments: ExtractCommentsOptions;
parallel: boolean;
parallel: number | boolean;
include: Rules | undefined;
exclude: Rules | undefined;
minimizer: {
Expand Down

0 comments on commit 1e14230

Please sign in to comment.