Skip to content

withDevtools() produces type errors for class based Signal Stores #165

@mh03r932

Description

@mh03r932

Hello,

First of all thank you for this great extension!

After updating to angular 19 and ngrx-signal store 19 withState produces typing error for class based signalStores if they have class fields.

Here is a very simple example that reproduces the problem. It modifies the example class based signal store from the ngrx faq

import {withDevtools} from '@angular-architects/ngrx-toolkit';
import {computed, Injectable} from '@angular/core';
import {patchState, signalStore, withState} from '@ngrx/signals';

@Injectable()
export class CounterStore extends signalStore(
  { protectedState: false },
  withState({ count: 0 }),
  withDevtools('counter-store')
) {

  readonly myReadonlyProp = 42; // this produces a type error

  readonly doubleCount = computed(() => this.count() * 2);

  increment(): void {
    patchState(this, { count: this.count() + 1 });
  }
}

Expected behaviour: no type error
Observed behaviour: TS2411: Property myReadonlyProp of type 42 is not assignable to string index type (newName?: unknown) => unknown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions