docs: explain Types global namespace#292
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new section titled 'Types Global Namespace' to the Redux documentation in both README.md and README_SOURCE.md. This section explains how to use an ambient module, MyTypes, to manage cross-cutting application types such as RootState and RootAction. Review feedback suggests improving consistency by using the tsx language tag for all code blocks, standardizing the import style for the MyTypes module, and removing unnecessary blank lines in code examples.
|
|
||
| This keeps the dependency direction simple. Feature modules export their own action, state, selector, and service types. The root store or service barrel composes those exports into application-wide types, and consumers import only the stable names they need: | ||
|
|
||
| ```ts |
There was a problem hiding this comment.
| This keeps the dependency direction simple. Feature modules export their own action, state, selector, and service types. The root store or service barrel composes those exports into application-wide types, and consumers import only the stable names they need: | ||
|
|
||
| ```ts | ||
| import { RootAction, RootState, Services } from 'MyTypes'; |
There was a problem hiding this comment.
This example introduces named imports from the MyTypes module (e.g., import { RootAction, ... }). However, existing examples throughout the guide (such as at lines 692 and 1803) use a default import style: import MyTypes from 'MyTypes'.
To maintain a consistent teaching pattern and avoid confusing readers, it would be beneficial to either update the existing examples to use named imports or explicitly mention that named imports are the preferred approach for this pattern.
| } | ||
|
|
|
Pushed dbf56bd to address the review feedback around the code fence language and import-style consistency. The generated service snippet still preserves its source-file trailing newline through generate-readme.js, so I left that generator behavior unchanged to keep this PR focused. |
|
Pushed a small follow-up in 1bcd2c8 to address the automated review nits: removed the trailing blank line from the generated code block and clarified that this section uses named imports while the existing namespace-style examples remain valid where grouped access is clearer. |
Fixes #97.
This adds a short section explaining the project-wide
MyTypesambient module, how feature areas extend it from the files that own those types, and how thetypesafe-actionsTypesaugmentation keepsRootActionavailable to helpers without re-declaring it in each feature.Validation:
npm run ci-checkgit diff --check