1
- import { ParameterType } from "./common.js" ;
2
- import { HardhatRuntimeEnvironment } from "./hre.js" ;
1
+ import type { ParameterType , ParameterTypeToValueType } from "./common.js" ;
2
+ import type { HardhatRuntimeEnvironment } from "./hre.js" ;
3
3
4
4
// We add the TaskManager to the HRE with a module augmentation to avoid
5
5
// introducing a circular dependency that would look like this:
@@ -182,11 +182,11 @@ export interface NewTaskDefinitionBuilder {
182
182
* The default value, if provided, should be of the same type as the
183
183
* parameter.
184
184
*/
185
- addNamedParameter ( paramOptions : {
185
+ addNamedParameter < T extends ParameterType > ( paramOptions : {
186
186
name : string ;
187
187
description ?: string ;
188
- type ?: ParameterType ;
189
- defaultValue ?: any ;
188
+ type ?: T ;
189
+ defaultValue ?: ParameterTypeToValueType < T > ;
190
190
} ) : this;
191
191
192
192
/**
@@ -210,11 +210,11 @@ export interface NewTaskDefinitionBuilder {
210
210
* optional, and any other positional parameters after it must also be
211
211
* optional.
212
212
*/
213
- addPositionalParameter ( paramOptions : {
213
+ addPositionalParameter < T extends ParameterType > ( paramOptions : {
214
214
name : string ;
215
215
description ?: string ;
216
- type ?: ParameterType ;
217
- defaultValue ?: any ;
216
+ type ?: T ;
217
+ defaultValue ?: ParameterTypeToValueType < T > ;
218
218
} ) : this;
219
219
220
220
/**
@@ -231,11 +231,11 @@ export interface NewTaskDefinitionBuilder {
231
231
* Note that this parameter must be the last positional parameter. No other
232
232
* positional parameter can follow it, including variadic parameters.
233
233
*/
234
- addVariadicParameter ( paramOptions : {
234
+ addVariadicParameter < T extends ParameterType > ( paramOptions : {
235
235
name : string ;
236
236
description ?: string ;
237
- type ?: ParameterType ;
238
- defaultValue ?: any [ ] ;
237
+ type ?: T ;
238
+ defaultValue ?: Array < ParameterTypeToValueType < T > > ;
239
239
} ) : this;
240
240
241
241
/**
@@ -253,30 +253,30 @@ export interface TaskOverrideDefinitionBuilder {
253
253
*/
254
254
setDescription ( description : string ) : this;
255
255
256
+ /**
257
+ * Sets a new action for the task.
258
+ *
259
+ * @see NewTaskDefinitionBuilder.setAction
260
+ */
261
+ setAction ( action : TaskOverrideActionFunction | string ) : this;
262
+
256
263
/**
257
264
* Adds a new named parameter to the task.
258
265
*
259
266
* @see NewTaskDefinitionBuilder.addNamedParameter
260
267
*/
261
- addNamedParameter ( paramOptions : {
268
+ addNamedParameter < T extends ParameterType > ( paramOptions : {
262
269
name : string ;
263
270
description ?: string ;
264
- type ?: ParameterType ;
265
- defaultValue : any ;
271
+ type ?: T ;
272
+ defaultValue ?: ParameterTypeToValueType < T > ;
266
273
} ) : this;
267
274
268
275
/**
269
276
* Adds a named parameter of boolean type and default value false.
270
277
*/
271
278
addFlag ( paramOptions : { name : string ; description ?: string } ) : this;
272
279
273
- /**
274
- * Sets a new action for the task.
275
- *
276
- * @see NewTaskDefinitionBuilder.setAction
277
- */
278
- setAction ( action : TaskOverrideActionFunction | string ) : this;
279
-
280
280
/**
281
281
* Builds the TaskOverrideDefinition.
282
282
*/
0 commit comments