Skip to content

Commit 87eea04

Browse files
fix(devtools): set types of withDevtools to EmptyFeatureResult
This fixes an issue with SignalStore's used to extend from, where `withDevtools` messed up the typing. Closes: #164, #165
1 parent 6c498b3 commit 87eea04

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { computed } from '@angular/core';
2+
import { patchState, signalStore, withState } from '@ngrx/signals';
3+
import { withDevtools } from '../with-devtools';
4+
5+
it('should compile when signalStore is extended from', () => {
6+
class CounterStore extends signalStore(
7+
{ protectedState: false },
8+
withState({ count: 0 }),
9+
withDevtools('counter-store')
10+
) {
11+
readonly myReadonlyProp = 42;
12+
13+
readonly doubleCount = computed(() => this.count() * 2);
14+
15+
increment(): void {
16+
patchState(this, { count: this.count() + 1 });
17+
}
18+
}
19+
});

Diff for: libs/ngrx-toolkit/src/lib/devtools/with-devtools.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { signalStoreFeature, withHooks, withMethods } from '@ngrx/signals';
1+
import {
2+
EmptyFeatureResult,
3+
SignalStoreFeature,
4+
signalStoreFeature,
5+
withHooks,
6+
withMethods,
7+
} from '@ngrx/signals';
28
import { inject, InjectionToken } from '@angular/core';
39
import { DevtoolsSyncer } from './internal/devtools-syncer.service';
410
import {
@@ -71,5 +77,5 @@ export function withDevtools(name: string, ...features: DevtoolsFeature[]) {
7177
},
7278
};
7379
})
74-
);
80+
) as SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult>;
7581
}

0 commit comments

Comments
 (0)