# TypeScript Guide

Use Marked with TypeScript.

## Type-Safe Configuration

```typescript { .api }
import { marked, MarkedOptions, Token, Tokens } from "marked";

const options: MarkedOptions = {
  gfm: true,
  breaks: true
};

marked.setOptions(options);
```

## Type Guards

```typescript { .api }
import { marked, Token, Tokens } from "marked";

function processToken(token: Token): void {
  if (token.type === 'heading') {
    // TypeScript knows this is Tokens.Heading
    console.log(`Level ${token.depth}: ${token.text}`);
  }
}
```

## Custom Extensions

```typescript { .api }
import { marked, MarkedExtension } from "marked";

const extension: MarkedExtension = {
  extensions: [{
    name: 'custom',
    level: 'inline',
    tokenizer(src: string) {
      // TypeScript-safe tokenizer
      return undefined;
    }
  }]
};

marked.use(extension);
```

## Type Definitions

Full TypeScript support with comprehensive type definitions included.
