> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codecrafters.io/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript

> Learn how to solve CodeCrafters challenges in TypeScript

## Local development

To run the code for your challenge locally, you'll need `bun` [installed](https://bun.sh/docs/installation). Our test runners use Bun v1.1 (as of May 2024).

The script for your challenge (like `./your_grep.sh`) will run your code using this version of `bun`. It'll
look something like this:

```sh theme={null}
#!/bin/sh

exec bun run app/main.ts "$@"
```

## File structure

* The files for your solution are placed in the `app/` directory.
* `app/main.ts` is the entrypoint for the program.

## Adding more files

You can add more files and directories to `app/`. The test runner will include them when compiling your code.

For example, if you add a file at `app/foo.ts`, you could use it like so:

```typescript app/main.ts theme={null}
import { foo, bar } from "./foo";

function main() {
  foo(); // Uses the foo function from foo.ts
  bar(); // Uses the bar function from foo.ts
}
```

```typescript app/foo.ts theme={null}
export function foo() {
    console.log('Hello from foo!');
}

export function bar() {
  console.log("Hello from bar!");
}
```

Refer to the Bun [documentation](https://bun.sh/docs/runtime/modules) for additional details.

> [!NOTE]
>
> Remember to add the `export` keyword to functions and variables that you want
> to export.

## Adding dependencies

You can add dependencies to your project using `bun add`.

For example, to add `zod` as a dependency, run the following command:

```bash theme={null}
bun add zod
```

This will add the following line to your `package.json` file:

```json theme={null}
{
  "dependencies": {
    "zod": "^3.0.0"
  }
}
```

It will also update the `bun.lockb` file.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.