Skip to content

Commit 1e14230

Browse files
fix: types for the parallel option (#448)
1 parent 210a5a0 commit 1e14230

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,17 @@ import { minify as minimize } from "./minify";
123123
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
124124
*/
125125

126+
/**
127+
* @typedef {undefined | boolean | number} Parallel
128+
*/
129+
126130
/**
127131
* @typedef {Object} BasePluginOptions
128132
* @property {Rules} [test]
129133
* @property {Rules} [include]
130134
* @property {Rules} [exclude]
131135
* @property {ExtractCommentsOptions} [extractComments]
132-
* @property {boolean} [parallel]
136+
* @property {Parallel} [parallel]
133137
*/
134138

135139
/**
@@ -307,7 +311,7 @@ class TerserPlugin {
307311

308312
/**
309313
* @private
310-
* @param {boolean | undefined} parallel
314+
* @param {Parallel} parallel
311315
* @returns {number}
312316
*/
313317
static getAvailableNumberOfCores(parallel) {

types/index.d.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ export type MinimizeFunctionHelpers = {
8080
};
8181
export type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
8282
MinimizeFunctionHelpers;
83+
export type Parallel = undefined | boolean | number;
8384
export type BasePluginOptions = {
8485
test?: Rules | undefined;
8586
include?: Rules | undefined;
8687
exclude?: Rules | undefined;
8788
extractComments?: ExtractCommentsOptions | undefined;
88-
parallel?: boolean | undefined;
89+
parallel?: Parallel;
8990
};
9091
export type InferDefaultType<T> = T extends infer U
9192
? U
@@ -188,13 +189,16 @@ export type DefinedDefaultMinimizerAndOptions<T> =
188189
* @template T
189190
* @typedef {BasicMinimizerImplementation<T> & MinimizeFunctionHelpers } MinimizerImplementation
190191
*/
192+
/**
193+
* @typedef {undefined | boolean | number} Parallel
194+
*/
191195
/**
192196
* @typedef {Object} BasePluginOptions
193197
* @property {Rules} [test]
194198
* @property {Rules} [include]
195199
* @property {Rules} [exclude]
196200
* @property {ExtractCommentsOptions} [extractComments]
197-
* @property {boolean} [parallel]
201+
* @property {Parallel} [parallel]
198202
*/
199203
/**
200204
* @template T
@@ -232,7 +236,7 @@ declare class TerserPlugin<T = TerserOptions> {
232236
private static buildError;
233237
/**
234238
* @private
235-
* @param {boolean | undefined} parallel
239+
* @param {Parallel} parallel
236240
* @returns {number}
237241
*/
238242
private static getAvailableNumberOfCores;
@@ -253,7 +257,7 @@ declare class TerserPlugin<T = TerserOptions> {
253257
options: {
254258
test: Rules;
255259
extractComments: ExtractCommentsOptions;
256-
parallel: boolean;
260+
parallel: number | boolean;
257261
include: Rules | undefined;
258262
exclude: Rules | undefined;
259263
minimizer: {

0 commit comments

Comments
 (0)