> For AI agents: the complete Sanity documentation index is available at [https://www.sanity.io/docs/llms.txt](https://www.sanity.io/docs/llms.txt).

# Using TypeScript in Sanity Studio

How to use TypeScript with Sanity Studio

TypeScript is a superset of JavaScript that adds optional static typing to the language. To learn more, see [TypeScript for JavaScript Programmers](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) in the TypeScript handbook.

If you initialize a studio with the Sanity CLI, TypeScript is the default. Sanity Studio uses [Vite](https://vite.dev/guide/features#typescript) to perform the transpilation of TypeScript files.

> [!WARNING]
> Use .tsx for files with JSX
> If you customize your studio with React components written in [JSX syntax](https://react.dev/learn/writing-markup-with-jsx), give those files a `.tsx` extension.

## Inline documentation with TSDoc

The Sanity Studio codebase uses TSDoc for inline documentation. You can check whether an API is internal, alpha, beta, or public:

- `@internal`: Not considered as stable for public consumption. If you rely on internal APIs, they might break between minor [semver](https://semver.org/) releases.
- `@alpha`: Experimental APIs at an earlier stage than `@beta` APIs. They might change or be replaced between minor [semver](https://semver.org/) releases.
- `@beta`: APIs that we intend to ship as public-facing, but that we are testing externally and might be subject to change between minor [semver](https://semver.org/) releases. We make a best effort to document breaking changes for `@beta` APIs in the release notes.
- `@public`: These are public APIs that you can use confidently. Breaking changes happen only in major [semver](https://semver.org/) releases and are documented.

## Default `tsconfig.json` file

If you initialize a studio project with the Sanity CLI and don't opt out of TypeScript, the CLI generates the following `tsconfig.json`:

**tsconfig.json**

```json
{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "Preserve",
    "moduleDetection": "force",
    "isolatedModules": true,
    "jsx": "preserve",
    "noUncheckedSideEffectImports": false,
    "incremental": true
  },
  "include": ["**/*.ts", "**/*.tsx"],
  "exclude": ["node_modules"]
}
```

