npm package: @orderly.network/ts-config
Description: Shared TypeScript configuration published on npm. Use it in any project via `extends` in your `tsconfig.json` for consistent compiler options across Node, React libraries, and Next.js apps.
Latest version: 0.0.2

# @orderly.network/ts-config

Shared TypeScript configuration published on npm. Use it in any project via `extends` in your `tsconfig.json` for consistent compiler options across Node, React libraries, and Next.js apps.

## Installation

Install as a dev dependency:

```bash
npm install -D @orderly.network/ts-config
```

Or with pnpm / yarn:

```bash
pnpm add -D @orderly.network/ts-config
yarn add -D @orderly.network/ts-config
```

## Usage

In your `tsconfig.json`, set `extends` to one of the provided configs:

- **Base (Node / general library):** `@orderly.network/ts-config/base.json`
- **React library:** `@orderly.network/ts-config/react-library.json`
- **Next.js app:** `@orderly.network/ts-config/nextjs.json`

Example:

```json
{
  "extends": "@orderly.network/ts-config/base.json",
  "compilerOptions": {
    "outDir": "dist"
  },
  "include": ["src"]
}
```

After installing from npm, TypeScript resolves `extends` from `node_modules` automatically.

## Presets

| Preset            | File                 | Use case                                        | Key options                                                                                                             |
| ----------------- | -------------------- | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **Base**          | `base.json`          | Default config for Node or general TS libraries | ES2020, `declaration` + `declarationMap`, `strict`, `isolatedModules`, `moduleResolution: "node"`                       |
| **React Library** | `react-library.json` | React component libraries, SDKs with JSX        | Extends base; `jsx: "react-jsx"`, `lib: ["ES2017", "DOM"]`, `module: "ESNext"`                                          |
| **Next.js**       | `nextjs.json`        | Next.js applications                            | Extends base; Next plugin, `allowJs`, `noEmit`, `jsx: "preserve"`, `strict: false`, `include: ["src", "next-env.d.ts"]` |

### base.json

- `target`: ES2020
- `declaration` + `declarationMap`: enabled
- `strict`: true
- `isolatedModules`, `skipLibCheck`, `esModuleInterop`, `forceConsistentCasingInFileNames`
- `exclude`: `["node_modules"]`

### react-library.json

Extends `base.json` and adds/overrides:

- `jsx`: `"react-jsx"`
- `lib`: `["ES2017", "DOM"]`
- `module`: `"ESNext"`
- `target`: ES2020

### nextjs.json

Extends `base.json` and adds/overrides:

- `plugins`: `[{ "name": "next" }]`
- `allowJs`, `noEmit`, `incremental`, `resolveJsonModule`
- `jsx`: `"preserve"`
- `lib`: `["dom", "dom.iterable", "esnext"]`
- `module`: `"esnext"`
- `strict`: false
- `target`: `"ESNext"`
- `declaration` / `declarationMap`: false
- `include`: `["src", "next-env.d.ts"]`
- `exclude`: `["node_modules"]`

## Examples

**Node or general library:**

```json
{
  "extends": "@orderly.network/ts-config/base.json",
  "include": ["src"]
}
```

**React library:**

```json
{
  "extends": "@orderly.network/ts-config/react-library.json",
  "include": ["src"]
}
```

**Next.js app:**

```json
{
  "extends": "@orderly.network/ts-config/nextjs.json"
}
```

## Extending and overrides

You can override or add any `compilerOptions` (and other fields) in your project’s `tsconfig.json`. The extended config is applied first, then your options are merged on top.