First, install the following dependencies:
bashnpm install --save-dev typescript @types/react @types/react-dom
CORE CONCEPTS
Rasengan.js provides a TypeScript-first development experience for building your React application.
It comes with built-in TypeScript support for automatically installing the necessary packages and configuring the proper settings.
create-rasengan
CLI can be used to create a new TypeScript project.
bashnpx create-rasengan@latest my-app
During the project creation, you will be prompted to choose the language for your project. Select TypeScript
to create a TypeScript project.
If you have an existing project and want to add TypeScript support, you have to follow the following steps:
First, install the following dependencies:
bashnpm install --save-dev typescript @types/react @types/react-dom
Then, add the following tsconfig.json
file to the root of your project.
json{ "compilerOptions": { "baseUrl": ".", "target": "ES2020", /* Bundler mode */ "moduleResolution": "bundler", "module": "ESNext", "jsx": "react-jsx", /* Aliases for intellisence */ "paths": { "@/*": ["src/*"] } }, "include": ["src", "rasengan-env.d.ts"], "extends": "./node_modules/rasengan/tsconfig.base.json" }
Finally, add the following rasengan-env.d.ts
file to the root of your project.
ts/// <reference types="rasengan/types/client" />
Finally, rename your files to .tsx
and .ts
extensions.
Then run npm run dev
to start the development server.
bashnpm run dev