# Step 1: Type Definition

**Only required for TypeScript users**

To maintain strong typing on custom tokens, you should extend the built-in `RegExpToken` interface with the type of your custom token.

```ts
// Import the interface and helper types (as needed)
import { RegExpToken, LiteralFunction, GenericFunction, IncompleteToken } from 'readable-regexp';

// Extend the interface with a declaration
declare module 'readable-regexp' {
  interface RegExpToken {

    // ===== CONSTANT tokens =====

    severity: RegExpToken;
    matchAll: RegExpToken;

    // ===== DYNAMIC tokens =====
    // Dynamic tokens must intersect the IncompleteToken type to signify that parameters are required

    // Use the LiteralFunction type for tokens that take a single string parameter
    notExactly: LiteralFunction & IncompleteToken;
    // Use the GenericFunction type for all other dynamic tokens
    // Use a union for function overloading
    exactValue: GenericFunction<[num: number] | [bool: boolean], RegExpToken> & IncompleteToken;

    // ===== MIXED tokens =====

    alpha: GenericFunction<[upper: boolean], RegExpToken> & RegExpToken;

  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hlysine.gitbook.io/readable-regexp/custom-extensions/custom-tokens/step-1-type-definition.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
