---
id: "packages/typescript-config/getting-started"
title: "Getting started"
description: "Take over typescript-config in a new or an existing repository, extend a preset, and run the first type-check."
url: "/packages/typescript-config/getting-started"
locale: "en"
revision: "6f2b778d37301b78"
---

# Getting started

These steps were carried out in a new, empty pnpm workspace outside every source repository, with
a copy of the package folder and nothing else: no path to Foundation and no other source.

## A new repository

## Copy the package

Take the folder `packages/typescript-config` from Foundation as a whole, without `node_modules`,
and place it unchanged at `packages/typescript-config` in your repository. Keep its bytes exact:

```text
# .gitattributes
packages/** -text
```

Then check that your copy equals the source, file by file:

```bash
diff -rq -x node_modules -x .turbo <foundation>/packages/typescript-config packages/typescript-config
```

No output means equal. Record where the copy came from (see
[Development basis](/development-basis#record-where-it-came-from)).

## Declare and install

Declare the package once, at the root, and install TypeScript in each package or app that
type-checks, with the type packages its preset needs:

```json
{
  "devDependencies": {
    "@workspace/typescript-config": "workspace:*"
  }
}
```

```json
{
  "devDependencies": {
    "@types/node": "^26",
    "typescript": "^6.0.3"
  }
}
```

| Preset | Your package or app also needs |
| --- | --- |
| `nodejs.json` | `@types/node` |
| `react-library.json` | `@types/react` (and `react`), for JSX |
| `nextjs.json` | `next`, `react`, `@types/react`, and Next's `next-env.d.ts` |

```bash
pnpm install
```

## Extend a preset

In each package or app, a `tsconfig.json` that extends the preset for its kind of code
([Presets](/packages/typescript-config/presets)) and names its own files:

```json
{
  "extends": "@workspace/typescript-config/nodejs.json",
  "include": ["src"],
  "exclude": ["node_modules", "dist"]
}
```

## Type-check

```json
{
  "scripts": {
    "typecheck": "tsc --noEmit"
  }
}
```

```bash
pnpm --filter <package> typecheck
```

`tsc` exits with 0 and no output when the types are correct, and with 2 and a list of errors when
they are not. Unlike lint, there is no threshold: one type error fails the run.

## An existing repository

| Your repository | What to do |
| --- | --- |
| has no `packages/typescript-config` | the steps above |
| has a copy at `packages/typescript-config` from another source | compare it with `diff -rq`, then replace the whole folder by Foundation's copy, never single files, and update your record of where it came from |
| has its own `tsconfig` settings, without this package | extend a preset and remove every setting the preset already carries; keep only `include`, `exclude`, output, `paths`, `types` and `plugins` ([Extending](/packages/typescript-config/extending)) |

After switching, run the type-check of every package and app. The shared base is strict:
`noUncheckedIndexedAccess` in particular reports index access that a looser configuration
accepted. Those errors are work of your repository; they are not solved by relaxing the option.

## Updating

There is no transfer tooling for this package. When Foundation has a new state, replace the whole
folder in one go, compare it with `diff -rq`, read the
[changelog](/packages/typescript-config/changelog), and run your type-checks. Your copy is never
edited in place: a change you need is made in Foundation and reaches you with the next copy.
