# AGENTS.md — core-typescript

**Tag:** tooling

Shared TypeScript base configs (`tsconfig.json` files) and Vitest base config, consumed by all packages.

## Why `@repo/core-testing` is not a devDependency here

Plan 7 Step 9 originally said to add it. Doing so creates a circular dependency
because `@repo/core-testing` already depends on `@repo/core-typescript` for its
own tsconfig. The base configs reference `@repo/core-testing/setup/{node,jsdom}`
as STRING paths in `setupFiles` — these are resolved at Vitest execution time
by the consuming feature package, not by `core-typescript` itself. Each feature
package therefore lists `@repo/core-testing` in its own `devDependencies`.

## What it owns

- **`base.json`** — Base `tsconfig.json`: target ES2022, module ESM, `experimentalDecorators` + `emitDecoratorMetadata` for InversifyJS
- **`nextjs.json`** — Next.js app config: extends base, adds `jsx: "preserve"`, Next.js lib types
- **`react-library.json`** — React library config: extends base, adds `jsx: "react-jsx"`, DOM lib
- **`vitest.base.ts`** — Vitest base config: globals, isolate modules, common ignore patterns

## How packages consume them

Packages extend the appropriate base:

```json
// packages/blog/tsconfig.json
{
  "extends": "@repo/core-typescript/base.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "dist",
    "lib": ["ES2022"]
  },
  "include": ["src/**/*"]
}
```

Apps extend Next.js config:

```json
// apps/web-next/tsconfig.json
{
  "extends": "@repo/core-typescript/nextjs.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": ".next"
  }
}
```

Vitest configs import the base:

```typescript
// packages/blog/vitest.config.ts
import { defineConfig } from "vitest/config";
import path from "path";
import { vitestBase } from "@repo/core-typescript";

export default defineConfig({
  ...vitestBase,
  test: {
    environment: "node",
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
});
```

## Test conventions

- No unit tests (config validation via `pnpm typecheck` in other packages)
- Verify at CI: `pnpm typecheck` succeeds across all packages
- Type errors should propagate: `pnpm typecheck` fails on invalid source code

## Structure

```
base.json                    # ES2022, ESM, decorators
nextjs.json                  # Next.js-specific paths + lib
react-library.json           # React JSX + DOM
vitest.base.ts               # Vitest defaults (globals, isolate)
package.json                 # Exports above files
```
