Skip to content

Commit ae754dc

Browse files
authored
refactor: update type definitions to fix Rslint issues (#11798)
* refactor: update type definitions to fix Rslint issues * fix * fix
1 parent 7b4ecd8 commit ae754dc

33 files changed

+106
-117
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"lint:js": "pnpm run lint-ci:js --write",
3434
"lint-ci:js": "biome check --diagnostic-level=warn --no-errors-on-unmatched --max-diagnostics=none --error-on-warnings",
3535
"lint:rs": "node ./scripts/check_rust_dependency.cjs",
36-
"lint:type": "rslint --config rslint.json --max-warnings=2602",
36+
"lint:type": "rslint --config rslint.json --max-warnings=2486",
3737
"build:binding:dev": "pnpm --filter @rspack/binding run build:dev",
3838
"build:binding:debug": "pnpm --filter @rspack/binding run build:debug",
3939
"build:binding:ci": "pnpm --filter @rspack/binding run build:ci",

packages/rspack/etc/core.api.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ type CacheHookMap = Map<string, SyncBailHook<[any[], StatsFactoryContext], any>[
583583
export type CacheOptions = boolean;
584584

585585
// @public (undocumented)
586-
type Callback_2 = (stats?: Stats | MultiStats | undefined) => any;
586+
type Callback_2 = (stats?: Stats | MultiStats) => any;
587587

588588
// @public (undocumented)
589589
type CallbackCache<T> = (err?: WebpackError_2 | null, result?: T) => void;
@@ -671,7 +671,7 @@ export type CircularDependencyRspackPluginOptions = {
671671
failOnError?: boolean;
672672
allowAsyncCycles?: boolean;
673673
exclude?: RegExp;
674-
ignoredConnections?: Array<[string | RegExp, string | RegExp]>;
674+
ignoredConnections?: [string | RegExp, string | RegExp][];
675675
onDetected?(entrypoint: Module, modules: string[], compilation: Compilation): void;
676676
onIgnored?(entrypoint: Module, modules: string[], compilation: Compilation): void;
677677
onStart?(compilation: Compilation): void;
@@ -878,7 +878,7 @@ export class Compilation {
878878
// (undocumented)
879879
chunkGraph: ChunkGraph;
880880
// (undocumented)
881-
get chunkGroups(): ReadonlyArray<ChunkGroup>;
881+
get chunkGroups(): readonly ChunkGroup[];
882882
// (undocumented)
883883
get chunks(): ReadonlySet<Chunk>;
884884
// (undocumented)
@@ -930,7 +930,7 @@ export class Compilation {
930930
getAssetPath(filename: string, data?: PathData): string;
931931
// (undocumented)
932932
getAssetPathWithInfo(filename: string, data?: PathData): binding.PathWithInfo;
933-
getAssets(): ReadonlyArray<Asset>;
933+
getAssets(): readonly Asset[];
934934
// (undocumented)
935935
getCache(name: string): CacheFacade;
936936
// (undocumented)
@@ -2343,9 +2343,9 @@ export type ExperimentCacheNormalized = boolean | {
23432343
buildDependencies: string[];
23442344
version: string;
23452345
snapshot: {
2346-
immutablePaths: Array<string | RegExp>;
2347-
unmanagedPaths: Array<string | RegExp>;
2348-
managedPaths: Array<string | RegExp>;
2346+
immutablePaths: (string | RegExp)[];
2347+
unmanagedPaths: (string | RegExp)[];
2348+
managedPaths: (string | RegExp)[];
23492349
};
23502350
storage: {
23512351
type: "filesystem";
@@ -2361,9 +2361,9 @@ export type ExperimentCacheOptions = boolean | {
23612361
buildDependencies?: string[];
23622362
version?: string;
23632363
snapshot?: {
2364-
immutablePaths?: Array<string | RegExp>;
2365-
unmanagedPaths?: Array<string | RegExp>;
2366-
managedPaths?: Array<string | RegExp>;
2364+
immutablePaths?: (string | RegExp)[];
2365+
unmanagedPaths?: (string | RegExp)[];
2366+
managedPaths?: (string | RegExp)[];
23672367
};
23682368
storage?: {
23692369
type: "filesystem";
@@ -2938,10 +2938,10 @@ interface HasSpan {
29382938
}
29392939

29402940
// @public (undocumented)
2941-
type Headers_2 = Array<{
2941+
type Headers_2 = {
29422942
key: string;
29432943
value: string;
2944-
}> | Record<string, string | string[]>;
2944+
}[] | Record<string, string | string[]>;
29452945

29462946
// @public (undocumented)
29472947
type HistoryApiFallbackOptions = {
@@ -3002,7 +3002,7 @@ export type HotUpdateMainFilename = FilenameTemplate;
30023002
export const HtmlRspackPlugin: typeof HtmlRspackPluginImpl & {
30033003
getHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
30043004
getCompilationHooks: (compilation: Compilation) => HtmlRspackPluginHooks;
3005-
createHtmlTagObject: (tagName: string, attributes?: Record<string, string | boolean>, innerHTML?: string | undefined) => JsHtmlPluginTag;
3005+
createHtmlTagObject: (tagName: string, attributes?: Record<string, string | boolean>, innerHTML?: string) => JsHtmlPluginTag;
30063006
version: number;
30073007
};
30083008

@@ -4842,7 +4842,7 @@ export interface MultiCompilerOptions {
48424842
}
48434843

48444844
// @public (undocumented)
4845-
export type MultiRspackOptions = ReadonlyArray<RspackOptions> & MultiCompilerOptions;
4845+
export type MultiRspackOptions = readonly RspackOptions[] & MultiCompilerOptions;
48464846

48474847
// @public (undocumented)
48484848
export class MultiStats {
@@ -5150,7 +5150,7 @@ export type Optimization = {
51505150
moduleIds?: "named" | "natural" | "deterministic";
51515151
chunkIds?: "natural" | "named" | "deterministic" | "size" | "total-size";
51525152
minimize?: boolean;
5153-
minimizer?: Array<"..." | Plugin_2>;
5153+
minimizer?: ("..." | Plugin_2)[];
51545154
mergeDuplicateChunks?: boolean;
51555155
splitChunks?: false | OptimizationSplitChunksOptions;
51565156
runtimeChunk?: OptimizationRuntimeChunk;
@@ -5748,7 +5748,7 @@ type ProvidesV1Config = {
57485748
};
57495749

57505750
// @public (undocumented)
5751-
type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request_2 | undefined, res?: Response_2 | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[];
5751+
type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request_2, res?: Response_2, next?: NextFunction) => ProxyConfigArrayItem))[];
57525752

57535753
// @public (undocumented)
57545754
type ProxyConfigArrayItem = {
@@ -5975,7 +5975,7 @@ type RealPathSync = {
59755975
// @public (undocumented)
59765976
type RecursiveArrayOrRecord<T> = {
59775977
[index: string]: RecursiveArrayOrRecord<T>;
5978-
} | Array<RecursiveArrayOrRecord<T>> | T;
5978+
} | RecursiveArrayOrRecord<T>[] | T;
59795979

59805980
// @public (undocumented)
59815981
interface RegExpLiteral extends Node_4, HasSpan {
@@ -6196,8 +6196,8 @@ const RsdoctorPluginImpl: {
61966196

61976197
// @public (undocumented)
61986198
type RsdoctorPluginOptions = {
6199-
moduleGraphFeatures?: boolean | Array<"graph" | "ids" | "sources">;
6200-
chunkGraphFeatures?: boolean | Array<"graph" | "assets">;
6199+
moduleGraphFeatures?: boolean | ("graph" | "ids" | "sources")[];
6200+
chunkGraphFeatures?: boolean | ("graph" | "assets")[];
62016201
sourceMapFeatures?: {
62026202
module?: boolean;
62036203
cheap?: boolean;

packages/rspack/src/Compilation.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
441441
);
442442
}
443443

444-
get chunkGroups(): ReadonlyArray<ChunkGroup> {
444+
get chunkGroups(): readonly ChunkGroup[] {
445445
return this.#inner.chunkGroups;
446446
}
447447

@@ -570,8 +570,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
570570
// properties in the prototype chain
571571
const options: Partial<NormalizedStatsOptions> = {};
572572
for (const key in optionsOrPreset) {
573-
options[key as keyof NormalizedStatsOptions] =
574-
optionsOrPreset[key as keyof StatsValue];
573+
options[key] = optionsOrPreset[key as keyof StatsValue];
575574
}
576575
if (options.preset !== undefined) {
577576
this.hooks.statsPreset.for(options.preset).call(options, context);
@@ -651,7 +650,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
651650
/**
652651
* Get an array of Asset
653652
*/
654-
getAssets(): ReadonlyArray<Asset> {
653+
getAssets(): readonly Asset[] {
655654
const assets = this.#inner.getAssets();
656655

657656
return assets.map(asset => {

packages/rspack/src/Diagnostics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function createDiagnosticArray(
125125
value: RspackError,
126126
index: number,
127127
array: RspackError[]
128-
) => U | ReadonlyArray<U>,
128+
) => U | readonly U[],
129129
thisArg?: This
130130
): U[] {
131131
return adm.values().flatMap(callbackfn, thisArg);

packages/rspack/src/ExecuteModulePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class ExecuteModulePlugin {
1515
const moduleObject = options.moduleObject;
1616
const source = options.codeGenerationResult.get("javascript");
1717
if (source === undefined) return;
18-
const code = source as string;
18+
const code = source;
1919

2020
try {
2121
const fn = vm.runInThisContext(

packages/rspack/src/MultiCompiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface MultiCompilerOptions {
5151
parallelism?: number;
5252
}
5353

54-
export type MultiRspackOptions = ReadonlyArray<RspackOptions> &
54+
export type MultiRspackOptions = readonly RspackOptions[] &
5555
MultiCompilerOptions;
5656

5757
export class MultiCompiler {

packages/rspack/src/Watching.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ export class Watching {
320320
});
321321
return;
322322
}
323-
this._done(null, this.compiler._lastCompilation!);
323+
this._done(null, this.compiler._lastCompilation);
324324
};
325325

326326
this.compiler.compile(onCompiled);
@@ -425,7 +425,7 @@ export class Watching {
425425
}
426426
});
427427
for (const cb of cbs) cb(null);
428-
this.compiler.hooks.afterDone.call(stats!);
428+
this.compiler.hooks.afterDone.call(stats);
429429
});
430430
}
431431

packages/rspack/src/builtin-loader/swc/pluginImport.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ type RawPluginImportConfig = {
1313
style?: RawStyleConfig;
1414
camelToDashComponentName?: boolean;
1515
transformToDefaultImport?: boolean;
16-
ignoreEsComponent?: Array<string>;
17-
ignoreStyleComponent?: Array<string>;
16+
ignoreEsComponent?: string[];
17+
ignoreStyleComponent?: string[];
1818
};
1919

2020
type PluginImportConfig = {

packages/rspack/src/builtin-plugin/CircularDependencyRspackPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type CircularDependencyRspackPluginOptions = {
3636
* module "app/design/components/Button.tsx". When the entry is a RegExp,
3737
* it is tested against the entire identifier.
3838
*/
39-
ignoredConnections?: Array<[string | RegExp, string | RegExp]>;
39+
ignoredConnections?: [string | RegExp, string | RegExp][];
4040
/**
4141
* Called once for every detected cycle. Providing this handler overrides the
4242
* default behavior of adding diagnostics to the compilation.

packages/rspack/src/builtin-plugin/DefinePlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ type NormalizedCodeValue = RecursiveArrayOrRecord<NormalizedCodeValuePrimitive>;
6969

7070
type RecursiveArrayOrRecord<T> =
7171
| { [index: string]: RecursiveArrayOrRecord<T> }
72-
| Array<RecursiveArrayOrRecord<T>>
72+
| RecursiveArrayOrRecord<T>[]
7373
| T;

0 commit comments

Comments
 (0)