Combine reducers with intersected type of unions causes tsc to crash
See original GitHub issueTypeScript Version: 3.4.0-dev.201xxxxx Typescript version: 3.4.5
Search Terms: Redux combine reducers memory crash heap allocation
Code
// es6 import statements for actions and reducers
type FormActions = SignUpFormActionTypes &
LoginFormActionTypes &
ContactUsFormActionTypes &
ForgotPasswordFormActionTypes &
ResetPasswordFormActionTypes &
CreateBusinessFormActionTypes &
BusinessDetailsFormActionTypes &
DealFormActionsTypes &
InstantDealFormActionsTypes &
JobListingFormActionTypes &
OnlineLocationFormActionTypes &
PhysicalLocationFormActionTypes;
export default combineReducers<FormsState, FormActions>({
signUpForm: SignUpFormReducer,
loginForm: LoginFormReducer,
contactUsForm: ContactUsFormReducer,
forgotPasswordForm: ForgotPasswordFormReducer,
resetPasswordForm: ResetPasswordFormReducer,
createBusinessForm: CreateBusinessFormReducer,
businessDetailsForm: BusinessDetailsFormReducer,
dealForm: DealFormReducer,
instantDealForm: InstantDealFormReducer,
jobListingForm: JobListingFormReducer,
onlineLocationForm: OnlineLocationFormReducer,
physicalLocationForm: PhysicalLocationFormReducer,
});
For example, an action type looks like this:
export type LoginFormActionTypes =
| SubmitLoginAction
| LoginSuccessAction
| LoginFailedAction;
And each of those actions are plain javascript classes that implement from Action<> in the redux library
Expected behavior: Should run tsc without issues
Actual behavior: npx tsc
<— Last few GCs —>
[59352:0000023E65B36200] 42665 ms: Mark-sweep 1391.2 (1425.2) -> 1390.9 (1425.7) MB, 966.8 / 0.0 ms (average mu = 0.081, current mu = 0.003) allocation failure scavenge might not succeed [59352:0000023E65B36200] 43644 ms: Mark-sweep 1391.8 (1425.7) -> 1391.4 (1426.2) MB, 952.3 / 0.0 ms (average mu = 0.055, current mu = 0.027) allocation failure scavenge might not succeed
<— JS stacktrace —>
==== JS stack trace =========================================
0: ExitFrame [pc: 000002A7DB3DC5C1]
1: StubFrame [pc: 000002A7DB3A26EE]
Security context: 0x030e7eb1e6e1 <JSObject> 2: slice [0000030E7EB06D09](this=0x03034251dc11 <JSArray[12]>,0) 3: /* anonymous /(aka / anonymous */) [000003034251DCC9] [D:\Workspace\business-portal\node_modules\typescript\lib\tsc.js:~33214] [pc=000002A7DC4AFFD1](this=0x0054b7c826f1 <undefined>,t=0x0074346aaf91 <Type map = 0000002A182ED9C9>) 4: argu…
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF79DD9ECF5 2: 00007FF79DD781A6 3: 00007FF79DD78BB0 4: 00007FF79E009AAE 5: 00007FF79E0099DF 6: 00007FF79E547724 7: 00007FF79E53DE87 8: 00007FF79E53C3FC 9: 00007FF79E545377 10: 00007FF79E5453F6 11: 00007FF79E0E84B7 12: 00007FF79E18019A 13: 000002A7DB3DC5C1
When I replace the action type of combineReducers to combineReducers<FormsState, any>, tsc runs and webpack compiles with linting.
These are my compiler options in tsconfig
"compilerOptions: {
"outDir": "dist",
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"declaration": false,
"noFallthroughCasesInSwitch": true,
"importHelpers": true,
"noEmitHelpers": true,
"noImplicitAny": true,
"skipLibCheck": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"isolatedModules": true,
"allowJs": true,
"checkJs": true,
"module": "es2015",
"noImplicitReturns": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"strict": true,
"pretty": true,
"removeComments": true,
"target": "es5",
"jsx": "react"
}
When I remove two or more declared action(s) that are part of the intersected FormActions type, tsc compiles again.
Related Issues:
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
How can one reproduce this without knowing the types of your Actions and Reducers?
Also please fix the formatting of the opening post. It’s a pain to read.
I have no recollection of why this ceased to be
Needs Investigation
or why I grabbed it.