Replies: 2 comments
-
See #3654 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks Tim. I thought I'd done a pretty thorough search for 'useDefineForClassFields' - not sure why I didn't find that. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary: Setting
useDefineForClassFields: true
intsconfig.json
appears to break the common NRGX Effects constructor pattern.I'm upgrading a project from A17 to A18 and encountered a problem with NGRX effects. I did not upgrade the project in place - I created a brand new A18 project and copied the code in.
To demonstrate with simplest possible root effect:
This worked fine in my A17 project but failed in my A18 project with:
Typescript versions were different (5.4.5 in A17 and 5.5.4 in A18) but the difference appears to be the change in
useDefineForClassFields
intsconfig.json
: this was explicitly set tofalse
in my A17 tsconfig but not present in my A18 tsconfig, and as it is using ES2022 defaulted totrue
.Examining the compiled JS appears to show the problem:
useDefineForClassFields: false
useDefineForClassFields: true
When
useDefineForClassFields
istrue
the property initialisation does not appear to get moved up in to the constructor, sothis.actions$
has not been set whentestEffect
is assigned.A couple of easy workarounds:
useDefineForClassFields: false
intsconfig.json
Not sure if this is intended behaviour in TS or not, but posting this here in case it helps anyone else trying to work out what was going on.
May be related to microsoft/TypeScript#48814
Beta Was this translation helpful? Give feedback.
All reactions