![]() ![]() React Redux has its type definitions in a separate typedefs package on NPM. RTK is already written in TypeScript, and its API is designed to provide a good experience for TypeScript usage. Redux Toolkit (RTK) is the standard approach for writing modern Redux logic. We assume that a typical Redux project is using Redux Toolkit and React Redux together. Standard Redux Toolkit Project Setup with TypeScript Following these patterns should result in a good TS usage experience, with the best tradeoffs between type safety and amount of type declarations you have to add to your codebase. This page shows our standard recommended patterns for using Redux and TypeScript together, and is not an exhaustive guide. There are multiple possible approaches to type checking Redux code. We believe that pragmatic use of TypeScript provides more than enough value and benefit to justify the added overhead, especially in larger codebases, but you should take time to evaluate the tradeoffs and decide whether it's worth using TS in your own application. ![]() At the same time, it provides value by catching errors earlier in development, enabling safer and more efficient refactoring, and acting as documentation for existing source code. It adds complexity in terms of writing additional code, understanding TS syntax, and building the application. However, like all tools, TypeScript has tradeoffs. ![]() We strongly recommend using TypeScript in Redux applications.
0 Comments
Leave a Reply. |