fix: resolve's plugins types

This commit is contained in:
alexander.akait 2024-03-04 19:59:16 +03:00
parent bf95762d16
commit cf891a4164
7 changed files with 79 additions and 32 deletions

View File

@ -333,6 +333,21 @@ export type ResolveAlias =
*/
[k: string]: string[] | false | string;
};
/**
* Plugin instance.
*/
export type ResolvePluginInstance =
| {
/**
* The run point of the plugin, required method.
*/
apply: (arg0: import("enhanced-resolve").Resolver) => void;
[k: string]: any;
}
| ((
this: import("enhanced-resolve").Resolver,
arg1: import("enhanced-resolve").Resolver
) => void);
/**
* A list of descriptions of loaders applied.
*/
@ -1643,16 +1658,6 @@ export interface ResolveOptions {
*/
useSyncFileSystemCalls?: boolean;
}
/**
* Plugin instance.
*/
export interface ResolvePluginInstance {
/**
* The run point of the plugin, required method.
*/
apply: (resolver: import("enhanced-resolve").Resolver) => void;
[k: string]: any;
}
/**
* Options object for node compatibility features.
*/

File diff suppressed because one or more lines are too long

View File

@ -4154,17 +4154,25 @@
},
"ResolvePluginInstance": {
"description": "Plugin instance.",
"anyOf": [
{
"type": "object",
"additionalProperties": true,
"properties": {
"apply": {
"description": "The run point of the plugin, required method.",
"instanceof": "Function",
"tsType": "(resolver: import('enhanced-resolve').Resolver) => void"
"tsType": "(arg0: import('enhanced-resolve').Resolver) => void"
}
},
"required": ["apply"]
},
{
"instanceof": "Function",
"tsType": "((this: import('enhanced-resolve').Resolver, arg1: import('enhanced-resolve').Resolver) => void)"
}
]
},
"RuleSetCondition": {
"description": "A condition matcher.",
"cli": {

View File

@ -0,0 +1 @@
export default 1;

View File

@ -0,0 +1,3 @@
it("should compile", async () => {
expect(1).toBe(1);
});

View File

@ -0,0 +1,26 @@
let pluginExecutionCounter = 0;
/** @type {import("../../../../").Configuration} */
module.exports = {
plugins: [
{
apply(compiler) {
compiler.hooks.done.tap("TestPlugin", () => {
expect(pluginExecutionCounter).toBe(4);
});
}
}
],
resolve: {
plugins: [
{
apply() {
pluginExecutionCounter += 1;
}
},
() => {
pluginExecutionCounter += 1;
}
]
}
};

20
types.d.ts vendored
View File

@ -10837,7 +10837,14 @@ declare interface ResolveOptionsWebpackOptions {
| false
| ""
| 0
| ResolvePluginInstance
| {
[index: string]: any;
/**
* The run point of the plugin, required method.
*/
apply: (arg0: Resolver) => void;
}
| ((this: Resolver, arg1: Resolver) => void)
| "..."
)[];
@ -10885,18 +10892,15 @@ type ResolveOptionsWithDependencyType = ResolveOptionsWebpackOptions & {
dependencyType?: string;
resolveToContext?: boolean;
};
/**
* Plugin instance.
*/
declare interface ResolvePluginInstance {
type ResolvePluginInstance =
| {
[index: string]: any;
/**
* The run point of the plugin, required method.
*/
apply: (resolver: Resolver) => void;
apply: (arg0: Resolver) => void;
}
| ((this: Resolver, arg1: Resolver) => void);
type ResolveRequest = BaseResolveRequest & Partial<ParsedIdentifier>;
declare interface ResolvedContextFileSystemInfoEntry {
safeTime: number;