Getting the error “Error TS4023: Exported variable ‘X’ has or is using name ‘SIGNAL’ from external module “../node_modules/@angular/core/index” but cannot be named” while trying to use @ngrx/signals in Angular v18.1.4. Following is the code sample:
import {
signalStore,
withState,
withMethods,
patchState,
withComputed,
} from '@ngrx/signals';
import {computed} from '@angular/core';
export const AppStore = signalStore(
{providedIn: 'root'},
withState({
appConfig: {},
app: {},
id: ''
}),
withComputed(({app, appConfig, id}) => ({
app: computed(() => app()),
appConfig: computed(() => appConfig()),
})),
withMethods((store) => ({
setApp(app: any): void {
patchState(store, (state) => ({
...state,
app: app,
}));
},
setAppConfig(appConfig: any): void {
window.localStorage.setItem(
'ENV_CONSTANTS',
appConfig.constants ? JSON.stringify(appConfig.constants) : '',
);
patchState(store, (state) => ({
...state,
appConfig: appConfig,
id: appConfig.name
}));
},
reset(): void {
patchState(store, (state) => ({
appConfig: {},
app: {},
id: ''
}));
}
})),
);
Following are the dependencies:
Angular: v18.1.4
Ngrx/signals: v18.0.2
Node.js: v18.19.1