Skip to content
4 changes: 4 additions & 0 deletions .docusaurus_site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ workflow {

Supported languages include: `groovy`, `bash`, `python`, `javascript`, `java`, `yaml`, `json`, and many more.

### Runnable snippets

- Code snippets under `docs/snippets/` are runnable and covered by the docs tests.

### Images and assets

- Place images in `docs/_static/` or `static/`
Expand Down
26 changes: 22 additions & 4 deletions .docusaurus_site/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ module.exports = {
"script",
"working-with-files",
"process",
"process-typed",
"workflow",
"workflow-typed",
"notifications",
"secrets",
"sharing",
Expand All @@ -45,13 +43,34 @@ module.exports = {
type: "category",
label: "Modules",
collapsed: true,
link: { type: "doc", id: "modules/modules" },
items: [
"modules/modules",
"modules/using-modules",
"modules/developing-modules",
"modules/module-registry"
]
},
{
type: "category",
label: "Static typing",
collapsed: true,
link: { type: "doc", id: "static-typing" },
items: [
"process-typed",
{
type: "category",
label: "Workflows (typed)",
collapsed: true,
link: { type: "doc", id: "workflow-typed" },
items: [
"typed-parameters",
"typed-outputs",
"typed-workflows"
]
},
"reference/operator-typed"
]
},
{
type: "category",
label: "Software dependencies",
Expand Down Expand Up @@ -108,7 +127,6 @@ module.exports = {
},
"reference/process",
"reference/channel",
"reference/operator-typed",
"reference/operator"
]
},
Expand Down
22 changes: 0 additions & 22 deletions docs/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/migrations/25-10.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,6 @@ This feature addresses previous inconsistencies in timestamp representations.
[stdlib-types]: ../reference/stdlib-types
[strict-syntax-page]: ../strict-syntax
[workflow-output-def]: ../workflow#outputs
[workflow-typed-params]: ../workflow-typed#typed-parameters
[workflow-typed-params]: ../typed-parameters
[workflow-params-legacy]: ../workflow#parameters
[workflow-handlers]: ../notifications#workflow-handlers
2 changes: 1 addition & 1 deletion docs/migrations/26-04.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,4 @@ A Platform access token with appropriate permissions is required to download non
[stdlib-listDirectory]: ../reference/stdlib-types#listdirectory---iterablepath
[strict-syntax-page]: ../strict-syntax
[workflow-typed-page]: ../workflow-typed
[workflow-typed-params]: ../workflow-typed#typed-parameters
[workflow-typed-params]: ../typed-parameters
19 changes: 5 additions & 14 deletions docs/process-typed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@ process hello {
}
```

To use this feature:

1. Enable the [strict parser][strict-syntax-page] by setting the `NXF_SYNTAX_PARSER` environment variable to `v2`:

```bash
export NXF_SYNTAX_PARSER=v2
```

2. Set `nextflow.enable.types = true` in every script that uses typed processes.

See [Process (typed)][syntax-process-typed] for the complete syntax reference and [Migrating to static typing][migrating-static-types] to migrate existing code to static typing.
For an overview of static typing and how to enable it, see [Static typing][static-typing-page].
For the complete syntax reference, see [Process (typed)][syntax-process-typed].

## Inputs

Expand Down Expand Up @@ -239,7 +230,7 @@ process grep {
}
```

See [Inputs and outputs (typed)][process-reference-typed] for available stage directives.
For more information about the available stage directives, see [Inputs and outputs (typed)][process-reference-typed].

## Outputs

Expand Down Expand Up @@ -283,7 +274,7 @@ process echo {
}
```

See [Inputs and outputs (typed)][process-reference-typed] for available output functions.
For more information about the available output functions, see [Inputs and outputs (typed)][process-reference-typed].

### File outputs

Expand Down Expand Up @@ -388,6 +379,6 @@ Directives behave the same way as [legacy processes][process-directives].
[process-directives]: ./process#directives
[process-script]: ./process#script
[process-stub]: ./process#stub
[static-typing-page]: ./static-typing
[stdlib-types]: ./reference/stdlib-types
[strict-syntax-page]: ./strict-syntax
[syntax-process-typed]: ./reference/syntax#process-typed
6 changes: 6 additions & 0 deletions docs/process.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ process hello {

See [Process][syntax-process] for a full description of the process syntax.

:::note
This page describes the original process syntax. Nextflow also supports a [typed process syntax][process-typed-page] with statically typed inputs and outputs. See [Static typing][static-typing-page] for an overview.
:::

## Script

The `script` section defines, as a string expression, the script that is executed by the process.
Expand Down Expand Up @@ -1345,8 +1349,10 @@ process hello {
[process-reference-inputs]: ./reference/process#inputs
[process-reference-outputs]: ./reference/process#outputs
[process-template]: ./process#template
[process-typed-page]: ./process-typed
[script-closure]: ./script#closures
[script-tuples]: ./script#tuples
[static-typing-page]: ./static-typing
[stdlib-types-path]: ./reference/stdlib-types#path
[strict-syntax-page]: ./strict-syntax
[string-interpolation]: ./script#string-interpolation
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/operator-typed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ description: Reference for the core Nextflow operators recommended for use with

This page describes the core operators that are recommended for use with static typing.

See [Using operators with static typing](../tutorials/static-types-operators) for best practices when migrating existing code.

## collect

**`Channel<E> collect() -> Value<Bag<E>>`**
Expand Down
77 changes: 77 additions & 0 deletions docs/static-typing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Static typing
description: Overview of static typing in Nextflow, including typed processes, typed workflows, records, and how to migrate existing pipelines.
---

# 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][stdlib-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.

:::warning
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&nbsp;(typed)][process-typed-page] | Type annotations for process inputs and outputs, the `stage:` section, records, and tuples. |
| [Workflows&nbsp;(typed)][workflow-typed-page] | Type annotations across a workflow, covering [Typed parameters][typed-parameters-page] (the `params` block), [Typed outputs][typed-outputs-page] (the `output` block), and [Typed workflows][typed-workflows-page] (the `take:` and `emit:` sections). |
| [Operators&nbsp;(typed)][operator-typed-page] | The core operators recommended for static typing. |

## Enabling static typing

Static typing requires two settings:

1. Enable the [strict parser][strict-syntax-page] by setting the `NXF_SYNTAX_PARSER` environment variable to `v2`:

```bash
export NXF_SYNTAX_PARSER=v2
```

The strict parser is enabled by default in Nextflow 26.04 and later.

2. Set `nextflow.enable.types = true` in every script that uses typed processes or typed workflows:

```nextflow
nextflow.enable.types = true
```

The `params` block and `output` block 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][feature-flags-page].

## Migrating existing pipelines

Static typing is opt-in, and you can adopt it incrementally. To migrate an existing pipeline:

1. Make sure your code is compatible with the [strict parser][strict-syntax-page] and refactor any patterns that aren't supported in typed workflows. For more information about preparing existing code, see [Preparing for static typing][preparing-static-types].
2. Follow the [migration tutorial][migrating-static-types] to convert parameters, processes, and workflows to the typed syntax.
3. Replace legacy operators with their typed equivalents using [Using operators with static typing][migrating-static-types-operators].

## See also

Static typing builds on functionality documented in other sections:

- [Types][stdlib-types]: The type system that the annotations draw from, including records, collections, and dataflow types.
- [Strict syntax][strict-syntax-page]: The strict (`v2`) parser that static typing requires.
- [Feature flags][feature-flags-page]: Documents the `nextflow.enable.types` flag and related settings.
- [Syntax reference][syntax-page]: Gives the formal grammar for typed processes and workflows.

[feature-flags-page]: ./reference/feature-flags
[migrating-static-types]: ./tutorials/static-types
[migrating-static-types-operators]: ./tutorials/static-types-operators
[operator-typed-page]: ./reference/operator-typed
[preparing-static-types]: ./tutorials/static-types#preparing-for-static-typing
[process-typed-page]: ./process-typed
[stdlib-types]: ./reference/stdlib-types
[strict-syntax-page]: ./strict-syntax
[syntax-page]: ./reference/syntax
[typed-outputs-page]: ./typed-outputs
[typed-parameters-page]: ./typed-parameters
[typed-workflows-page]: ./typed-workflows
[workflow-typed-page]: ./workflow-typed
2 changes: 1 addition & 1 deletion docs/strict-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -720,4 +720,4 @@ For Groovy code that is complicated or if it depends on third-party libraries, i
[syntax-page]: ./reference/syntax
[workflow-handlers]: ./notifications#workflow-handlers
[workflow-params-legacy]: ./workflow#parameters
[workflow-typed-params]: ./workflow-typed#typed-parameters
[workflow-typed-params]: ./typed-parameters
6 changes: 2 additions & 4 deletions docs/tutorials/static-types-operators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ description: Best practices for using operators with static typing in Nextflow.

Nextflow 26.04 brings updates to the operator library in order to support static tying and records. This page provides best practices for using operators with static typing.

See [Migrating to static typing][migrating-static-types] for more information about migrating pipelines to static typing.

## Overview

All operators can be used with or without static typing (i.e. [typed workflows][workflow-typed-page]). However, only a core subset of operators are recommended for use with static typing, while the rest are discouraged. They are distinguished here as *core operators* and *legacy operators*.

See [Migrating to static typing][migrating-static-types] for more information about migrating pipelines to static typing.

## Core operators

The [core operators][operator-typed-page] are recommended for use with static typing. When static typing is enabled (via `nextflow.enable.types`), some of these operators have stricter semantics which may require minor changes to pipeline code. These cases are described below.
Expand Down
74 changes: 74 additions & 0 deletions docs/typed-outputs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: Typed outputs
description: Annotate workflow outputs in Nextflow using type annotations in the output block.
---

# Typed outputs

<AddedInVersion version="25.10" />

Workflow outputs can use type annotations:

```nextflow
nextflow.enable.types = true

params {
input: String
}

process fastqc {
input:
reads: Path

output:
file('fastqc')

// ...
}

process summary {
input:
logs: Path

output:
file('report.html')

// ...
}

workflow {
main:
ch_reads = channel.fromPath(params.input)
ch_fastqc = fastqc(ch_reads)
summary_report = summary(ch_fastqc.collect())

publish:
fastqc = ch_fastqc
summary_report = summary_report
}

output {
fastqc: Channel<Path> {
path '.'
}

summary_report: Path {
path '.'
}
}
```

In the above example, the workflow declares two outputs:

- `fastqc`: a channel of FastQC results (`Channel<Path>`)
- `summary_report`: a dataflow value containing a summary report (`Value<Path>` or `Path`)

## Features

Type annotations document the structure of each workflow output, and the language server uses them to validate the type of each published output.

Outputs that receive a dataflow value can be declared as `Value<V>` or `V` for short. In this example, the `summary_report` is declared with type `Path` as a shorthand for `Value<Path>`.

For more information about standard types, see [Types][stdlib-types].

[stdlib-types]: ./reference/stdlib-types
45 changes: 45 additions & 0 deletions docs/typed-parameters.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Typed parameters
description: Declare statically typed pipeline parameters in Nextflow using the params block.
---

# Typed parameters

<AddedInVersion version="25.10" />

A script can declare parameters using the `params` block:

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

// Whether to save intermediate files.
save_intermeds: Boolean
}

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

## Features

Parameters can use all [standard types][stdlib-types] except the dataflow types (`Channel` and `Value`).

Typed parameters should only be referenced in the entry workflow or `output` block. Parameters can be passed to workflows and processes as explicit inputs.

The command line, params file, or config file can override the default value. Parameters from multiple sources are resolved in the order described in [Pipeline parameters][cli-params]. Nextflow converts command-line parameters to the type set by their annotation.

A parameter that doesn't specify a default value is a *required* parameter. If a required parameter has no value at runtime, the run fails.

For more information about standard types, see [Types][stdlib-types].

<AddedInVersion version="26.04">

Boolean parameters that don't specify a default value default to `false`.

</AddedInVersion>

[cli-params]: ./cli#pipeline-parameters
[stdlib-types]: ./reference/stdlib-types
Loading
Loading