diff --git a/README.md b/README.md index 647b5c7..c46375e 100644 --- a/README.md +++ b/README.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."_ 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."_ 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": {