Skip to content

Commit bde3fdb

Browse files
committed
Use TaskArguments instead of ParsedTaskArguments
1 parent e04ccb1 commit bde3fdb

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

v-next/core/src/types/tasks.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ParameterType, ParameterTypeToValueType } from "./common.js";
1+
import type {
2+
ParameterType,
3+
ParameterTypeToValueType,
4+
ParameterValue,
5+
} from "./common.js";
26
import type { HardhatRuntimeEnvironment } from "./hre.js";
37

48
// We add the TaskManager to the HRE with a module augmentation to avoid
@@ -63,7 +67,7 @@ export interface PositionalTaskParameter<
6367
* A type representing the arguments or concrete parameters of a task. That is,
6468
* the actual values passed to it.
6569
*/
66-
export type TaskArguments = Record<string, any>;
70+
export type TaskArguments = Record<string, ParameterValue | ParameterValue[]>;
6771

6872
/**
6973
* The type of a new task's action function.

v-next/hardhat/src/internal/cli/main.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ import {
3434
} from "../helpers/config-loading.js";
3535
import { getHardhatRuntimeEnvironmentSingleton } from "../hre-singleton.js";
3636

37-
/**
38-
* The parsed arguments of a task. This is the result of parsing the raw
39-
* arguments passed to a task.
40-
*/
41-
interface ParsedTaskArguments extends TaskArguments {
42-
[key: string]: ParameterValue | ParameterValue[];
43-
}
44-
4537
export async function main(cliArguments: string[]) {
4638
const hreInitStart = performance.now();
4739

@@ -248,7 +240,7 @@ export function parseTaskAndArguments(
248240
):
249241
| {
250242
task: Task;
251-
taskArguments: ParsedTaskArguments;
243+
taskArguments: TaskArguments;
252244
}
253245
| string[] {
254246
const taskOrId = getTaskFromCliArguments(cliArguments, usedCliArguments, hre);
@@ -329,8 +321,8 @@ function parseTaskArguments(
329321
cliArguments: string[],
330322
usedCliArguments: boolean[],
331323
task: Task,
332-
): ParsedTaskArguments {
333-
const taskArguments: ParsedTaskArguments = {};
324+
): TaskArguments {
325+
const taskArguments: TaskArguments = {};
334326

335327
// Parse named parameters
336328
parseDoubleDashArgs(
@@ -362,7 +354,7 @@ function parseDoubleDashArgs(
362354
cliArguments: string[],
363355
usedCliArguments: boolean[],
364356
parametersMap: Map<string, NamedTaskParameter | GlobalParameter>,
365-
argumentsMap: ParsedTaskArguments,
357+
argumentsMap: TaskArguments,
366358
) {
367359
for (let i = 0; i < cliArguments.length; i++) {
368360
if (usedCliArguments[i]) {
@@ -450,7 +442,7 @@ function parsePositionalAndVariadicParameters(
450442
cliArguments: string[],
451443
usedCliArguments: boolean[],
452444
task: Task,
453-
taskArguments: ParsedTaskArguments,
445+
taskArguments: TaskArguments,
454446
) {
455447
let paramI = 0;
456448

@@ -503,7 +495,7 @@ function parsePositionalAndVariadicParameters(
503495

504496
function validateRequiredParameters(
505497
parameters: TaskParameter[],
506-
taskArguments: ParsedTaskArguments,
498+
taskArguments: TaskArguments,
507499
) {
508500
const missingRequiredParam = parameters.find(
509501
(param) =>

0 commit comments

Comments
 (0)