---
description: TypeScript conventions for @contentstack/utils (src and tests)
globs:
  - src/**/*.ts
  - __test__/**/*.ts
alwaysApply: false
---

# TypeScript — `@contentstack/utils`

## Tooling

- **TypeScript ~4.9** (`package.json`, `tsconfig.json`).
- **Bundler output:** `tsc` emits to `dist/lib` with declarations in `dist/types`; **Rollup** produces `dist/index.es.js` (`rollup.config.js`).
- **Strict mode** is on with **`strictNullChecks: false`** — new code should still minimize unnecessary null/undefined gaps when touching APIs.

## Layout

- **Library code:** `src/**/*.ts` only (`tsconfig.json` `include`); **tests** are under `__test__/` (excluded from `tsc` program but type-checked via Jest/tsconfig paths).
- **Public exports:** Maintain **`src/index.ts`** as the single export surface unless intentionally adding secondary entry points.

## Style and lint

- Match existing naming (PascalCase types, camelCase functions, existing file layout under `Models/`, `nodes/`, `helper/`, `options/`).
- **ESLint** flat config: `eslint.config.js` — `@typescript-eslint` recommended for `__test__`; source files use `js.configs.recommended` baseline.
- **Prettier:** `npm run format` scopes `src/**/*.ts`; keep formatting consistent when editing tests too.

## JSON / assets

- **`src/assets/regions.json`:** Consumed by `src/endpoints.ts`; populated by **`npm run download-regions`** during `prebuild`. Do not assume the file is committed (see root `.gitignore`).

## Logging

- No shared logger dependency; avoid introducing `console` noise in library paths unless consistent with nearby code.
