store
store copied to clipboard
🐞[BUG]: Can't use isolatedModules with NGXS
Affected Package
@ngxs/store 18.1.1
Is this a regression?
Yes, the previous version in which this bug was not present was: ....Description
When enabling the following typescript compile options:
"isolatedModules": true,
"useDefineForClassFields": true,
More info about these settings: Using isolatedModules in Angular 18.2
I then get this error: ERROR] TS1272: A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled. [plugin angular-compiler]
I can't import StateContext
in my states without using either:
import type { StateContext } from '@ngxs/store';
or
import Ngxs from '@ngxs/store
But when using these imports I get a runtime exception like this when using i.e. setState, getState etc.
TypeError: Cannot read properties of undefined (reading 'pipe')
this.store
.dispatch(new User.Get())
.pipe(
mergeMap(() =>
this.languageService.setLanguage().pipe(
🔥 Exception or Error
TypeError: Cannot read properties of undefined (reading 'pipe')
Environment
Libs:
- @angular/core version: 18.2.1
- @ngxs/store version: 18.1.1
Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: 20.15.1
- Platform: Mac
Others: