Shared tsconfig.json presets following best practices at Sanity.io
npm install @sanity/tsconfigShared tsconfig.json presets following best practices at Sanity.io
Add the package to your "devDependencies":
``sh`
npm install --save-dev @sanity/tsconfigor
pnpm add --save-dev @sanity/tsconfigor
yarn add --dev @sanity/tsconfig
Choose one of the presets as your base:
- [@sanity/tsconfig/recommended]@sanity/tsconfig/strict
- []@sanity/tsconfig/strictest
- []
You can optionally combine your base with [@sanity/tsconfig/isolated-declarations] if you're using build tools (like rolldown or tsdown) that can generate .d.ts files significantly faster when TypeScript is constrained with "isolatedDeclarations": true.
Add to your tsconfig.json:
`json`
{
"extends": "@sanity/tsconfig/recommended"
}
Add to your tsconfig.json:
`json`
{
"extends": "@sanity/tsconfig/strict"
}
Add to your tsconfig.json:
`json`
{
"extends": "@sanity/tsconfig/strictest"
}
Extend the isolated-declarations.json preset in addition to your base.tsconfig.json
If your previously looked like this:
`json`
{
"extends": "@sanity/tsconfig/strict"
}
Then change extends to an array and isolated-declarations to the end:
`json`
{
"extends": ["@sanity/tsconfig/strict", "@sanity/tsconfig/isolated-declarations"]
}
[@sanity/tsconfig/recommended]: #recommended-tsconfigjson@sanity/tsconfig/strict
[]: #strict@sanity/tsconfig/strictest
[]: #strictest@sanity/tsconfig/isolated-declarations`]: #isolated-declarations
[