Registry / web-framework / react-static-plugin-typescript

react-static-plugin-typescript

JSON →
library7.6.2jsnpmunverified

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.

npm install react-static-plugin-typescript
INSTALL
IMPORT
SIG · REACT-STATIC-PLUGI
R
react-static-plugin-typescript
web-frameworkjavascriptv7.6.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PluginConfiguration
export default { plugins: ['react-static-plugin-typescript'], }
import { ReactStaticTypeScriptPlugin } from 'react-static-plugin-typescript';
This plugin is configured by its string name within the `plugins` array in `static.config.js`; it does not export runtime symbols for direct import into user application code. `static.config.js` itself typically uses ESM `export default`.
PluginWithOptions
export default { plugins: [['react-static-plugin-typescript', { typeCheck: true }]], }
const pluginConfig = require('react-static-plugin-typescript'); // Incorrect for static.config.js and for passing options
To pass options to the plugin, wrap the plugin's string name and an options object in an array within the `plugins` array. This is the standard way for React Static plugins.

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"] }
Debug
Known issues
breakingNode.js v10 support was removed across the React Static v7.2.0 ecosystem, including this plugin. Projects now require Node.js v12 or higher for compatibility.
fix
Upgrade your Node.js environment to version 12 or newer to ensure the build process functions correctly.
affects: >=7.2.0
breakingThe `v7.6.0` release of React Static brought an update to its `emotion` plugin to support Emotion v11. If your project uses Emotion, this might introduce breaking changes requiring updates to your Emotion configuration and component styling.
fix
Refer to Emotion's v11 upgrade guide and adjust your Emotion setup and component code accordingly for compatibility.
affects: >=7.6.0
gotchaDisabling type checking via the `typeCheck: false` option can lead to uncaught TypeScript errors during compilation, potentially resulting in runtime issues that would otherwise be caught at build time.
fix
For robust development, it is highly recommended to keep `typeCheck: true` and resolve all TypeScript errors. Only disable it for specific performance needs, ensuring type safety is managed by other tools (e.g., editor, CI linting).
affects: All
gotchaMissing or incorrectly configured `tsconfig.json` will prevent the plugin from properly compiling TypeScript files, leading to build failures or unexpected behavior. Ensure it aligns with React and modern JavaScript practices.
fix
Ensure a valid `tsconfig.json` is present at the project root, typically including `jsx: "preserve"`, `lib: ["es2015", "dom"]`, and `moduleResolution: "node"`.
affects: All
gotchaThe `typescript` peer dependency must be installed in your project, along with `@types/react` as a dev dependency. Failure to do so will result in compilation errors or missing type definitions.
fix
Run `npm install typescript @types/react --save-dev` to ensure all necessary type tools are available for your project.
affects: All
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'typescript' in '...'
The `typescript` peer dependency is not installed in the project.
fix
Run `npm install typescript --save-dev` to install the TypeScript compiler.
ERROR in TS[...] Property '...' does not exist on type '...'.
A TypeScript type error was detected during compilation when `typeCheck` is enabled. This prevents the build from completing.
fix
Correct the TypeScript type errors in your source code. If the error is intentional or a temporary workaround, consider casting or modifying the type definitions. For faster local iteration, you may set `typeCheck: false` in the plugin options (not recommended for production builds).
Error: No default export for template [...]
A React Static template (e.g., a page component or `src/App.tsx`) is missing a default export, which is required by the framework.
fix
Ensure all React Static page components and `src/App.tsx` have a `export default MyComponent;` statement.
Failed to load tsconfig.json: [...]
The `tsconfig.json` file is either missing from the project root or contains invalid JSON syntax, preventing the TypeScript compiler from configuring correctly.
fix
Verify that `tsconfig.json` exists in your project's root directory and that its content is valid JSON. Use a JSON linter or editor to check for syntax errors.
Upgrade
Version history
7.6.2latest on npm
Audit
Dependencies
typescriptrequiredRequired peer dependency for TypeScript compilation and type checking.
@types/reactrequiredProvides essential type definitions for React components when working in TypeScript, although it's a dev dependency for the project rather than a peer dependency of the plugin.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
react-static-plugin-typescript — npm install react-static-plugin-typescript · libregistry