angularsignalsngrx

Angular Ngrx Signal store A type annotation is necessary Error


I am writing a signal store with Angular 18 and @ngrx/signals: ^17.2.0, the code is returning me this error:

error TS2742: The inferred type of 'x' cannot be named without a reference to '../../../../../../../node_modules/@ngrx/signals/src/deep-signal'.
This is likely not portable. A type annotation is necessary.

The error only appears when using a use nested object; with a non-nested object - it works.

The code:

import { signalStore, withState } from '@ngrx/signals';
import { SidebarSettingsState} from '../types';

const initialState: SidebarSettingsState = {
  theme: 'sidebar-dark',
  collapsed: false,
  logo: {
    theme: 'bg-blue',
  },
};

export const SidebarSettingsStore = signalStore(
  withState<SidebarSettingsState>(initialState)
);

I have tried many things, ChatGPT, TabNine, and adding type any, but these all have problems where the template is not accessing the data.


Solution

  • I see that a new version of signals just released, try: npm/yarn i @ngrx/signals@18.0.0-rc.1