From b5aac18aa7da0a2ff875aa65e12314d4763aa081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20Nesfeldt=20Eng=C3=B8y?= <140903820+TheodorNEngoy@users.noreply.github.com> Date: Thu, 15 May 2025 18:15:50 +0200 Subject: [PATCH 1/3] docs: add Dispatched Action Types section to README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 647b5c7..4826c13 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +## Dispatched Action Types + +When you dispatch an action creator, the **type** of the action is inferred by TypeScript. +To see the actual string literal used under the hood, use the `getType` helper from `typesafe-actions`: + +```ts +import { createAction, getType } from 'typesafe-actions'; + +// Define an action +const addTodo = createAction('todos/ADD', resolve => { + return (text: string) => resolve({ text }); +}); + +// Infer its type +type AddTodo = ReturnType; +console.log(getType(addTodo)); // logs: 'todos/ADD' + +
# React & Redux in TypeScript - Complete Guide From 17b8ae0c424118204929d6dbdab845f0357c4fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20Nesfeldt=20Eng=C3=B8y?= <140903820+TheodorNEngoy@users.noreply.github.com> Date: Thu, 15 May 2025 19:23:28 +0200 Subject: [PATCH 2/3] docs: add Dispatched Action Types to README_SOURCE and regenerate README --- README.md | 9 +++------ README_SOURCE.md | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4826c13..c46375e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +
+ ## Dispatched Action Types When you dispatch an action creator, the **type** of the action is inferred by TypeScript. @@ -6,17 +8,12 @@ To see the actual string literal used under the hood, use the `getType` helper f ```ts import { createAction, getType } from 'typesafe-actions'; -// Define an action const addTodo = createAction('todos/ADD', resolve => { return (text: string) => resolve({ text }); }); -// Infer its type type AddTodo = ReturnType; -console.log(getType(addTodo)); // logs: 'todos/ADD' - - -
+console.log(getType(addTodo)); // 'todos/ADD' # React & Redux in TypeScript - Complete Guide diff --git a/README_SOURCE.md b/README_SOURCE.md index 358fcc3..3e09a97 100644 --- a/README_SOURCE.md +++ b/README_SOURCE.md @@ -1,5 +1,20 @@
+## Dispatched Action Types + +When you dispatch an action creator, the **type** of the action is inferred by TypeScript. +To see the actual string literal used under the hood, use the `getType` helper from `typesafe-actions`: + +```ts +import { createAction, getType } from 'typesafe-actions'; + +const addTodo = createAction('todos/ADD', resolve => { + return (text: string) => resolve({ text }); +}); + +type AddTodo = ReturnType; +console.log(getType(addTodo)); // 'todos/ADD' + # React & Redux in TypeScript - Complete Guide _"This guide is a **living compendium** documenting the most important patterns and recipes on how to use **React** (and its Ecosystem) in a **functional style** using **TypeScript**. It will help you make your code **completely type-safe** while focusing on **inferring the types from implementation** so there is less noise coming from excessive type annotations and it's easier to write and maintain correct types in the long run."_ From 2aa05e703b38d7d7bc1113cc478d304e26cf6238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Theodor=20Nesfeldt=20Eng=C3=B8y?= <140903820+TheodorNEngoy@users.noreply.github.com> Date: Thu, 15 May 2025 19:36:49 +0200 Subject: [PATCH 3/3] chore: add doctoc to devDependencies --- package-lock.json | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6ba6be0..987fe99 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ }, "devDependencies": { "all-contributors-cli": "6.9.3", - "doctoc": "1.4.0", + "doctoc": "^1.4.0", "husky": "3.0.9" } }, @@ -481,6 +481,7 @@ "resolved": "https://registry.npmjs.org/doctoc/-/doctoc-1.4.0.tgz", "integrity": "sha512-8IAq3KdMkxhXCUF+xdZxdJxwuz8N2j25sMgqiu4U4JWluN9tRKMlAalxGASszQjlZaBprdD2YfXpL3VPWUD4eg==", "dev": true, + "license": "MIT", "dependencies": { "@textlint/markdown-to-ast": "~6.0.9", "anchor-markdown-header": "^0.5.5", diff --git a/package.json b/package.json index ab9314a..13ea153 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "devDependencies": { "all-contributors-cli": "6.9.3", - "doctoc": "1.4.0", + "doctoc": "^1.4.0", "husky": "3.0.9" }, "scripts": {