Skip to content

Commit 7626423

Browse files
refactor: code
1 parent 6ededf3 commit 7626423

9 files changed

Lines changed: 19 additions & 16 deletions

test/__snapshots__/cache-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`"cache" option should work with the "false" value for the "cache" option: assets 1`] = `
44
{

test/__snapshots__/exclude-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`exclude option should match snapshot for a single RegExp value excluded1: assets 1`] = `
44
{

test/__snapshots__/include-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`include option should match snapshot for a single RegExp value included1: assets 1`] = `
44
{

test/__snapshots__/minimizerOptions-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`when applied with "minimizerOptions" option matches snapshot for "discardComments" option (disable): entry.css 1`] = `
44
"body{

test/__snapshots__/test-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`when applied with "test" option matches snapshot for a single "test" value (RegExp): assets 1`] = `
44
{

test/__snapshots__/warningsFilter-option.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`warningsFilter option should match snapshot for a "function" value: assets 1`] = `
44
{

test/__snapshots__/worker.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`worker should emit error: error 1`] = `
44
[

types/index.d.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ declare class CssMinimizerPlugin<T = CssNanoOptionsExtended> {
5959
* @param {Compiler} compiler Compiler
6060
* @param {Compilation} compilation Compilation
6161
* @param {Record<string, import("webpack").sources.Source>} assets Assets
62-
* @param {{availableNumberOfCores: number}} optimizeOptions Optimize options
62+
* @param {{ availableNumberOfCores: number }} optimizeOptions Optimize options
6363
* @returns {Promise<void>} Promise
6464
*/
6565
private optimize;
@@ -90,6 +90,7 @@ declare namespace CssMinimizerPlugin {
9090
Parser,
9191
Stringifier,
9292
TraceMap,
93+
EXPECTED_ANY,
9394
CssNanoOptions,
9495
Warning,
9596
WarningObject,
@@ -139,6 +140,7 @@ type Syntax = import("postcss").Syntax;
139140
type Parser = import("postcss").Parser;
140141
type Stringifier = import("postcss").Stringifier;
141142
type TraceMap = import("@jridgewell/trace-mapping").TraceMap;
143+
type EXPECTED_ANY = any;
142144
type CssNanoOptions = Record<string, unknown>;
143145
type Warning =
144146
| (Error & {
@@ -199,11 +201,11 @@ type MinimizedResult = {
199201
/**
200202
* Errors
201203
*/
202-
errors?: Array<Error | ErrorObject | string> | undefined;
204+
errors?: (Error | ErrorObject | string)[] | undefined;
203205
/**
204206
* Warnings
205207
*/
206-
warnings?: Array<Warning | WarningObject | string> | undefined;
208+
warnings?: (Warning | WarningObject | string)[] | undefined;
207209
};
208210
type Input = {
209211
[file: string]: string;
@@ -212,7 +214,7 @@ type CustomOptions = {
212214
[key: string]: unknown;
213215
};
214216
type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
215-
type MinimizerOptions<T> = T extends any[]
217+
type MinimizerOptions<T> = T extends EXPECTED_ANY[]
216218
? { [P in keyof T]?: InferDefaultType<T[P]> }
217219
: InferDefaultType<T>;
218220
type BasicMinimizerImplementation<T> = (
@@ -226,7 +228,7 @@ type MinimizeFunctionHelpers = {
226228
*/
227229
supportsWorkerThreads?: (() => boolean | undefined) | undefined;
228230
};
229-
type MinimizerImplementation<T> = T extends any[]
231+
type MinimizerImplementation<T> = T extends EXPECTED_ANY[]
230232
? {
231233
[P in keyof T]: BasicMinimizerImplementation<T[P]> &
232234
MinimizeFunctionHelpers;
@@ -257,18 +259,18 @@ type InternalResult = {
257259
/**
258260
* - Outputs
259261
*/
260-
outputs: Array<{
262+
outputs: {
261263
code: string;
262264
map: RawSourceMap | undefined;
263-
}>;
265+
}[];
264266
/**
265267
* - Warnings
266268
*/
267-
warnings: Array<Warning | WarningObject | string>;
269+
warnings: (Warning | WarningObject | string)[];
268270
/**
269271
* - Errors
270272
*/
271-
errors: Array<Error | ErrorObject | string>;
273+
errors: (Error | ErrorObject | string)[];
272274
};
273275
type Parallel = undefined | boolean | number;
274276
type Rule = RegExp | string;

types/utils.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export type Input = import("./index.js").Input;
33
export type RawSourceMap = import("./index.js").RawSourceMap;
44
export type MinimizedResult = import("./index.js").MinimizedResult;
55
export type CustomOptions = import("./index.js").CustomOptions;
6+
export type EXPECTED_ANY = import("./index.js").EXPECTED_ANY;
67
export type ProcessOptions = import("postcss").ProcessOptions;
78
export type Postcss = import("postcss").Postcss;
89
/**

0 commit comments

Comments
 (0)