Blog>
Snippets

Configuring TypeScript for TanStack React Charts

Show how to set up a TypeScript project to use TanStack React Charts, including installing types and configuring tsconfig.json.
npm i react-charts
Install the TanStack React Charts library into your React project.
npm i @types/react-charts
Install the TypeScript definitions for TanStack React Charts. Note: If official types are not available, this step might be unnecessary or replaced with a community types package.
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "react-jsx"
  },
  "include": ["src"]
}
Configure tsconfig.json for your project to ensure TypeScript works well with React and TanStack React Charts. This configuration includes essential compiler options for a modern React project using TypeScript.