> For the complete documentation index, see [llms.txt](https://darkobits.gitbook.io/saffron/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://darkobits.gitbook.io/saffron/typescript.md).

# TypeScript

Saffron supports strongly-typed arguments and configuration schemas. If type definitions exist for these, they may be passed to Saffron as type arguments and Saffron will ensure that the data passed to your `handler` is appropriately typed:

{% code title="cli.ts" %}

```typescript
import * as cli from '@darkobits/saffron';

interface Schema {
  spline: string;
  algorithm: 'RTA-20' | 'RTA-21' | 'RTA-22';
}

cli.command<Schema>({
  handler: ({ argv, config }) => {
    // argv is of type Schema.
    // config is of type Schema.
  }
});

cli.init();
```

{% endcode %}

If the schema for your application's arguments and configuration differs, a second type argument may be provided to distinguish the argument schema from the configuration schema:

{% code title="cli.ts" %}

```typescript
import * as cli from '@darkobits/saffron';

interface Arguments {
  spline: string;
  algorithm: 'RTA-20' | 'RTA-21' | 'RTA-22';
}

interface Configuration {
  // Configuration schema here.
}

cli.command<Arguments, Configuration>({
  handler: ({ argv, config }) => {
    // argv is of type Arguments.
    // config is of type Configuration.
  }
});

cli.init();
```

{% endcode %}
