Static typing
Static typing is optional. All existing code continues to work.
Static typing lets you model and validate the structure of your data as it flows through a pipeline. You add standard Nextflow types to inputs and outputs at every level, from pipeline parameters to process and workflow outputs. The Nextflow language server uses those annotations to catch type-related errors as you write code.
Some static typing features are previews. The syntax and behavior may change in future releases.
Static typing features
Static typing is a set of related language features. Each one applies type annotations at a different stage of a pipeline, and you can adopt them independently or together:
| Page | Description |
|---|---|
| Processes (typed) | Type annotations for process inputs and outputs, the stage: section, records, and tuples. |
| Workflows (typed) | Type annotations across a workflow, covering Typed parameters (the params block), Typed outputs (the output block), and Typed workflows (the take: and emit: sections). |
| Operators (typed) | The core operators recommended for static typing. |
Enabling static typing
Static typing requires two settings:
-
Enable the strict parser by setting the
NXF_SYNTAX_PARSERenvironment variable tov2:export NXF_SYNTAX_PARSER=v2The strict parser is enabled by default in Nextflow 26.04 and later.
-
Set
nextflow.enable.types = truein every script that uses typed processes or typed workflows:nextflow.enable.types = trueThe
paramsblock andoutputblock work without this flag.
A script with nextflow.enable.types = true cannot also contain legacy process or workflow definitions. For more information about feature flags, see Feature flags.
Migrating existing pipelines
Static typing is opt-in, and you can adopt it incrementally. To migrate an existing pipeline:
- Make sure your code is compatible with the strict parser and refactor any patterns that aren't supported in typed workflows. For more information about preparing existing code, see Preparing for static typing.
- Follow the migration tutorial to convert parameters, processes, and workflows to the typed syntax.
- Replace legacy operators with their typed equivalents using Using operators with static typing.
See also
Static typing builds on functionality documented in other sections:
- Types: The type system that the annotations draw from, including records, collections, and dataflow types.
- Strict syntax: The strict (
v2) parser that static typing requires. - Feature flags: Documents the
nextflow.enable.typesflag and related settings. - Syntax reference: Gives the formal grammar for typed processes and workflows.