Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 96c0fb8

Browse files
committed
✨ Automate adding new reducers key to RootState
1 parent 6f80c62 commit 96c0fb8

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

app/types/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RouterState } from 'connected-react-router';
33
import { ContainerState as LanguageProviderState } from 'containers/LanguageProvider/types';
44
import { ContainerState as AppState } from 'containers/App/types';
55
import { ContainerState as HomeState } from 'containers/HomePage/types';
6+
// [IMPORT NEW CONTAINERSTATE ABOVE] < Needed for generating continers seamlessly
67

78
export interface InjectedStore extends Store {
89
injectedReducers: any;
@@ -30,6 +31,8 @@ export interface ApplicationRootState {
3031
readonly global: AppState;
3132
readonly language: LanguageProviderState;
3233
readonly home: HomeState;
34+
// [INSERT NEW REDUCER KEY ABOVE] < Needed for generating continers seamlessly
35+
3336
// for testing purposes
3437
readonly test: any;
3538
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
readonly {{ camelCase name }}: {{ properCase name }}State;
2+
// [INSERT NEW REDUCER KEY ABOVE] < Needed for generating continers seamlessly
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { ContainerState as {{ properCase name }}State } from 'containers/{{ properCase name }}/types';
2+
// [IMPORT NEW CONTAINERSTATE ABOVE] < Needed for generating continers seamlessly

internals/generators/container/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,20 @@ module.exports = {
184184
templateFile: './container/types.d.hbs',
185185
abortOnFail: true,
186186
});
187+
actions.push({
188+
type: 'modify',
189+
path: '../../app/types/index.d.ts',
190+
pattern: new RegExp(/.*\/\/.*\[IMPORT NEW CONTAINERSTATE ABOVE\].+\n\n*/),
191+
templateFile: './container/importContainerState.hbs',
192+
abortOnFail: true,
193+
});
194+
actions.push({
195+
type: 'modify',
196+
path: '../../app/types/index.d.ts',
197+
pattern: new RegExp(/.*\/\/.*\[INSERT NEW REDUCER KEY ABOVE\].+\n\n*/),
198+
templateFile: './container/appendApplicationRootState.hbs',
199+
abortOnFail: true,
200+
});
187201
}
188202

189203
actions.push({

internals/generators/container/index.tsx.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ interface Props {}
4545

4646
function {{ properCase name }}(props: Props) {
4747
{{#if wantActionsAndReducer}}
48-
// Warning: Add your key to RootState in types/index.d.ts file
4948
useInjectReducer({ key: '{{ camelCase name }}', reducer: reducer });
5049
{{/if}}
5150
{{#if wantSaga}}

0 commit comments

Comments
 (0)