This package provides a central configuration for Canonical's React Typescript projects.
This configuration extends a base configuration, which provides more general TypeScript settings and is suitable for non-React projects.
- Install Typescript:
bun add -d typescript
- Install this configuration:
bun add -d @canonical/typescript-config-react
- Create a
tsconfig.json
file in the root of your project and extend this configuration.
{
"extends": "@canonical/typescript-config-react"
}
This configuration enables the following behavior:
-
DOM
library inclusion: Includes theDOM
library, providing types for the DOM and browser APIs. -
react-jsx
transform: Emits.jsx
as.js
with the new React JSX transform, optimized for production usage.
This configuration is rooted in the Canonical React Components Typescript config. It has been generalized to support non-React projects and be more minimal.
React-specific changes to the original config are listed below. For non-React relevant changes, see the base configuration README.
-
"jsx": "react"
→"jsx": "react-jsx"
: Transforms JSX to JS with modern React JSX optimizations, instead of with React.createElement. Enables usage of JSX without importing React.