angulartypescriptngrxangular-signals

Type 'Signal<boolean>' is not assignable to type 'Signal<unknown>'


I am working on an app which is using a pretty simple signal store. It worked the last days but suddenly today I got the following error:

Type 'Signal<boolean>' is not assignable to type 'Signal<unknown>'.
  Type 'Signal<boolean>' is not assignable to type '{ [SIGNAL]: unknown; }'.ts(2322)

The strange thing is that I didn't change anything, and the examples on the NgRx page are exactly the same. Even when I copy the code into another repository it works.

I already tried to reinstall everything even with different versions.

import { signalStore, withComputed, withState } from '@ngrx/signals';
import { computed } from '@angular/core';

type ProjectState = {
  projects: {name: string}[];
  isLoading: boolean;
};

const initialState: ProjectState = {
  projects: [{ name: 'test' }],
  isLoading: false
};

export const ProjectStore = signalStore(
  { providedIn: 'root' },
  withState(initialState),
  withComputed(({ projects }) => ({
    hasProjects: computed(() => !!projects().length)
  }))
);

I am using Angular 19.2.6, @ngrx/signals 19.1.0 and NX 20.8.0. What could cause this?


Solution

  • I am working on a nx library with an own package.json. I accidentally did an npm i in the library (not the root). A node_modules folder was created which lacked @ngrx/signals dependency. Looks like it tried to access it from there.

    I removed the node_modules folder from the library and it works. Maybe this helps someone.