React Static TypeScript Plugin

7.6.2 · maintenance · verified Sun Apr 19

The `react-static-plugin-typescript` package integrates TypeScript support into projects built with the React Static framework, enabling the use of `.ts` and `.tsx` files for components and application logic. The current stable version is 7.6.2. It operates by hooking into React Static's build pipeline to compile TypeScript code and offers an optional type-checking feature during compilation. This plugin is a core component for React Static users who prefer TypeScript for improved code maintainability and developer experience. Its release cadence is tightly coupled with the React Static framework's updates. Key differentiators include its seamless integration into the `static.config.js` file and its ability to toggle type-checking during development builds, providing flexibility for different workflow needs. The React Static ecosystem appears to be in a maintenance state, meaning this plugin follows a similar lifecycle.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install the plugin, add it to your `static.config.js` with options for type checking, and configure a basic `tsconfig.json` for a new or existing React Static project using TypeScript.

npm install react-static-plugin-typescript @types/react --save-dev

// static.config.js (in your project root)
export default {
  plugins: [
    // Add the TypeScript plugin, optionally with typeCheck enabled
    ['react-static-plugin-typescript', { typeCheck: true }]
  ],
  // Other React Static configurations...
}

// tsconfig.json (in your project root)
{
  "compilerOptions": {
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2015", "dom"],
    "moduleResolution": "node",
    "skipLibCheck": true,
    "isolatedModules": true,
    "noEmit": true,
    "allowJs": true,
    "jsx": "preserve",
    "sourceMap": true,
    "removeComments": false,
    "strict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true
  },
  "include": ["src"],
  "exclude": ["node_modules", "dist", "build"]
}

view raw JSON →