Skip to main content

Typed parameters

Added in version 25.10

Typed parameters let you declare a pipeline's parameters, their types, and their default values in a single params block. The Nextflow language server uses the annotations to validate every parameter reference against its declared type as you write code.

params {
// Path to input data.
input: Path

// Whether to save intermediate files.
save_intermeds: Boolean

// Maximum number of iterations.
max_iterations: Integer = 100
}

workflow {
analyze(params.input, params.save_intermeds, params.max_iterations)
}

The params block does not require the nextflow.enable.types feature flag. For an overview of static typing and how to enable it, see Static typing. For the complete syntax reference, see Params block.

Supported types

Parameters can use any standard type except the dataflow types (Channel and Value). This includes primitive types such as Path, String, Integer, and Boolean, as well as collections and records.

Default and required parameters

A parameter can optionally specify a default value:

  • A parameter that specifies a default value is optional. If no value is supplied at runtime, the default is used.
  • A parameter that does not specify a default value is required. If a required parameter has no value at runtime, the run fails.
Added in version 26.04

Boolean parameters that don't specify a default value default to false rather than being treated as required.

Input files declared as Path must already exist when the pipeline is launched. Use String for file paths that are created by the pipeline.

Overriding parameters

A parameter's default value can be overridden on the command line, in a params file, or in a config file. When a parameter is set from more than one source, Nextflow resolves the final value in the order described in Pipeline parameters.

Nextflow converts command-line parameters to the type set by their annotation. For example, a parameter declared as Integer receives an integer value, not the string entered on the command line.

Referencing parameters

Typed parameters should only be referenced in the entry workflow or the output block. To use a parameter elsewhere, pass it to a workflow or process as an explicit input.

Validation

The language server validates each parameter reference against its declared type. Referencing a parameter in a context that expects a different type is reported as an error before the pipeline runs.

See also