@ngrx/signals 19.2.1 → 20.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"find-module.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/find-module.ts"],"names":[],"mappings":";;AA8BA,sDA8BC;AAKD,gCA2BC;AAKD,8CAuBC;AAxHD;;;;;;GAMG;AACH,6CAS8B;AAW9B;;GAEG;AACH,SAAgB,qBAAqB,CACnC,IAAU,EACV,OAAsB;IAEtB,IAAI,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAC/D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACpB,IAAM,WAAW,GACf,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;YACpB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9D,OAAO,IAAA,gBAAS,EAAC,UAAU,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;IAClD,CAAC;SAAM,CAAC;QACN,IAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,GAAG,GAAG,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACxE,IAAM,cAAc,GAAG,IAAA,gBAAS,EAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAE9D,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5B,OAAO,IAAA,gBAAS,EAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,IAAI,CAAC,MAAM,CAAC,UAA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,CAAC;IACtE,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,UAAA;QACR,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AACD;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,QAA4B;IAC/D,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {\n Path,\n join,\n normalize,\n relative,\n strings,\n basename,\n extname,\n dirname,\n} from '@angular-devkit/core';\nimport { DirEntry, Tree } from '@angular-devkit/schematics';\n\nexport interface ModuleOptions {\n module?: string;\n name: string;\n flat?: boolean;\n path?: string;\n skipImport?: boolean;\n}\n\n/**\n * Find the module referred by a set of options passed to the schematics.\n */\nexport function findModuleFromOptions(\n host: Tree,\n options: ModuleOptions\n): Path | undefined {\n if (options.hasOwnProperty('skipImport') && options.skipImport) {\n return undefined;\n }\n\n if (!options.module) {\n const pathToCheck =\n (options.path || '') +\n (options.flat ? '' : '/' + strings.dasherize(options.name));\n\n return normalize(findModule(host, pathToCheck));\n } else {\n const modulePath = normalize('/' + options.path + '/' + options.module);\n const moduleBaseName = normalize(modulePath).split('/').pop();\n\n if (host.exists(modulePath)) {\n return normalize(modulePath);\n } else if (host.exists(modulePath + '.ts')) {\n return normalize(modulePath + '.ts');\n } else if (host.exists(modulePath + '.module.ts')) {\n return normalize(modulePath + '.module.ts');\n } else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {\n return normalize(modulePath + '/' + moduleBaseName + '.module.ts');\n } else {\n throw new Error(`Specified module path ${modulePath} does not exist`);\n }\n }\n}\n\n/**\n * Function to find the \"closest\" module to a generated file's path.\n */\nexport function findModule(host: Tree, generateDir: string): Path {\n let dir: DirEntry | null = host.getDir('/' + generateDir);\n\n const moduleRe = /\\.module\\.ts$/;\n const routingModuleRe = /-routing\\.module\\.ts/;\n\n while (dir) {\n const matches = dir.subfiles.filter(\n (p) => moduleRe.test(p) && !routingModuleRe.test(p)\n );\n\n if (matches.length == 1) {\n return join(dir.path, matches[0]);\n } else if (matches.length > 1) {\n throw new Error(\n 'More than one module matches. Use skip-import option to skip importing ' +\n 'the component into the closest module.'\n );\n }\n\n dir = dir.parent;\n }\n\n throw new Error(\n 'Could not find an NgModule. Use the skip-import ' +\n 'option to skip importing in NgModule.'\n );\n}\n\n/**\n * Build a relative path from one file path to another file path.\n */\nexport function buildRelativePath(from: string, to: string): string {\n const {\n path: fromPath,\n filename: fromFileName,\n directory: fromDirectory,\n } = parsePath(from);\n const {\n path: toPath,\n filename: toFileName,\n directory: toDirectory,\n } = parsePath(to);\n const relativePath = relative(fromDirectory, toDirectory);\n const fixedRelativePath = relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n\n return !toFileName || toFileName === 'index.ts'\n ? fixedRelativePath\n : `${\n fixedRelativePath.endsWith('/')\n ? fixedRelativePath\n : fixedRelativePath + '/'\n }${convertToTypeScriptFileName(toFileName)}`;\n}\n\nfunction parsePath(path: string) {\n const pathNormalized = normalize(path) as Path;\n const filename = extname(pathNormalized) ? basename(pathNormalized) : '';\n const directory = filename ? dirname(pathNormalized) : pathNormalized;\n return {\n path: pathNormalized,\n filename,\n directory,\n };\n}\n/**\n * Strips the typescript extension and clears index filenames\n * foo.ts -> foo\n * index.ts -> empty\n */\nfunction convertToTypeScriptFileName(filename: string | undefined) {\n return filename ? filename.replace(/(\\.ts)|(index\\.ts)$/, '') : '';\n}\n"]}
1
+ {"version":3,"file":"find-module.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/find-module.ts"],"names":[],"mappings":";;AA8BA,sDAkCC;AAKD,gCA2BC;AAKD,8CAuBC;AA5HD;;;;;;GAMG;AACH,6CAS8B;AAW9B;;GAEG;AACH,SAAg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,CAAC,CAAC,CAAC,cAAc,CAAC;IACtE,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,UAAA;QACR,SAAS,WAAA;KACV,CAAC;AACJ,CAAC;AACD;;;;GAIG;AACH,SAAS,2BAA2B,CAAC,QAA4B;IAC/D,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC","sourcesContent":["/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {\n Path,\n join,\n normalize,\n relative,\n strings,\n basename,\n extname,\n dirname,\n} from '@angular-devkit/core';\nimport { DirEntry, Tree } from '@angular-devkit/schematics';\n\nexport interface ModuleOptions {\n module?: string;\n name: string;\n flat?: boolean;\n path?: string;\n skipImport?: boolean;\n}\n\n/**\n * Find the module referred by a set of options passed to the schematics.\n */\nexport function findModuleFromOptions(\n host: Tree,\n options: ModuleOptions\n): Path | undefined {\n if (options.hasOwnProperty('skipImport') && options.skipImport) {\n return undefined;\n }\n\n if (!options.module) {\n const pathToCheck =\n (options.path || '') +\n (options.flat ? '' : '/' + strings.dasherize(options.name));\n\n return normalize(findModule(host, pathToCheck));\n } else {\n const modulePath = normalize('/' + options.path + '/' + options.module);\n const moduleBaseName = normalize(modulePath).split('/').pop();\n\n if (host.exists(modulePath)) {\n return normalize(modulePath);\n } else if (host.exists(modulePath + '.ts')) {\n return normalize(modulePath + '.ts');\n } else if (host.exists(modulePath + '.module.ts')) {\n return normalize(modulePath + '.module.ts');\n } else if (host.exists(modulePath + '/' + moduleBaseName + '.module.ts')) {\n return normalize(modulePath + '/' + moduleBaseName + '.module.ts');\n } else if (host.exists(modulePath + '-module.ts')) {\n return normalize(modulePath + '-module.ts');\n } else if (host.exists(modulePath + '/' + moduleBaseName + '-module.ts')) {\n return normalize(modulePath + '/' + moduleBaseName + '-module.ts');\n } else {\n throw new Error(`Specified module path ${modulePath} does not exist`);\n }\n }\n}\n\n/**\n * Function to find the \"closest\" module to a generated file's path.\n */\nexport function findModule(host: Tree, generateDir: string): Path {\n let dir: DirEntry | null = host.getDir('/' + generateDir);\n\n const moduleRe = /(\\.|-)module\\.ts$/;\n const routingModuleRe = /-routing(\\.|-)module\\.ts/;\n\n while (dir) {\n const matches = dir.subfiles.filter(\n (p) => moduleRe.test(p) && !routingModuleRe.test(p)\n );\n\n if (matches.length == 1) {\n return join(dir.path, matches[0]);\n } else if (matches.length > 1) {\n throw new Error(\n 'More than one module matches. Use skip-import option to skip importing ' +\n 'the component into the closest module.'\n );\n }\n\n dir = dir.parent;\n }\n\n throw new Error(\n 'Could not find an NgModule. Use the skip-import ' +\n 'option to skip importing in NgModule.'\n );\n}\n\n/**\n * Build a relative path from one file path to another file path.\n */\nexport function buildRelativePath(from: string, to: string): string {\n const {\n path: fromPath,\n filename: fromFileName,\n directory: fromDirectory,\n } = parsePath(from);\n const {\n path: toPath,\n filename: toFileName,\n directory: toDirectory,\n } = parsePath(to);\n const relativePath = relative(fromDirectory, toDirectory);\n const fixedRelativePath = relativePath.startsWith('.')\n ? relativePath\n : `./${relativePath}`;\n\n return !toFileName || toFileName === 'index.ts'\n ? fixedRelativePath\n : `${\n fixedRelativePath.endsWith('/')\n ? fixedRelativePath\n : fixedRelativePath + '/'\n }${convertToTypeScriptFileName(toFileName)}`;\n}\n\nfunction parsePath(path: string) {\n const pathNormalized = normalize(path) as Path;\n const filename = extname(pathNormalized) ? basename(pathNormalized) : '';\n const directory = filename ? dirname(pathNormalized) : pathNormalized;\n return {\n path: pathNormalized,\n filename,\n directory,\n };\n}\n/**\n * Strips the typescript extension and clears index filenames\n * foo.ts -> foo\n * index.ts -> empty\n */\nfunction convertToTypeScriptFileName(filename: string | undefined) {\n return filename ? filename.replace(/(\\.ts)|(index\\.ts)$/, '') : '';\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.platformVersion = void 0;
4
- exports.platformVersion = '^19.2.1';
4
+ exports.platformVersion = '^20.0.0-rc.0';
5
5
  //# sourceMappingURL=libs-version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/libs-version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,SAAS,CAAC","sourcesContent":["export const platformVersion = '^19.2.1';\n"]}
1
+ {"version":3,"file":"libs-version.js","sourceRoot":"","sources":["../../../../../modules/signals/schematics-core/utility/libs-version.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,cAAc,CAAC","sourcesContent":["export const platformVersion = '^20.0.0-rc.0';\n"]}
@@ -1,9 +1,5 @@
1
- import { Signal as NgSignal } from '@angular/core';
1
+ import { Signal } from '@angular/core';
2
2
  import { IsKnownRecord } from './ts-helpers';
3
- export interface Signal<T> extends NgSignal<T> {
4
- name: unknown;
5
- length: unknown;
6
- }
7
3
  export type DeepSignal<T> = Signal<T> & (IsKnownRecord<T> extends true ? Readonly<{
8
4
  [K in keyof T]: IsKnownRecord<T[K]> extends true ? DeepSignal<T[K]> : Signal<T[K]>;
9
5
  }> : unknown);
package/src/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { Prettify } from './ts-helpers';
10
10
  export { withComputed } from './with-computed';
11
11
  export { withFeature } from './with-feature';
12
12
  export { withHooks } from './with-hooks';
13
+ export { withLinkedState } from './with-linked-state';
13
14
  export { withMethods } from './with-methods';
14
15
  export { withProps } from './with-props';
15
16
  export { withState } from './with-state';
@@ -1,4 +1,4 @@
1
- import { WritableStateSource } from './state-source';
2
1
  import { DeepSignal } from './deep-signal';
2
+ import { WritableStateSource } from './state-source';
3
3
  export type SignalState<State extends object> = DeepSignal<State> & WritableStateSource<State>;
4
4
  export declare function signalState<State extends object>(initialState: State): SignalState<State>;
@@ -5,7 +5,7 @@ import { IsKnownRecord, Prettify } from './ts-helpers';
5
5
  export type StateSignals<State> = IsKnownRecord<Prettify<State>> extends true ? {
6
6
  [Key in keyof State]: IsKnownRecord<State[Key]> extends true ? DeepSignal<State[Key]> : Signal<State[Key]>;
7
7
  } : {};
8
- export type SignalsDictionary = Record<string, Signal<unknown>>;
8
+ export type SignalsDictionary = Record<string | symbol, Signal<unknown>>;
9
9
  export type MethodsDictionary = Record<string, Function>;
10
10
  export type SignalStoreHooks = {
11
11
  onInit?: () => void;
@@ -1,16 +1,20 @@
1
1
  import { Injector, Signal, WritableSignal } from '@angular/core';
2
- import { Prettify } from './ts-helpers';
3
2
  export declare const STATE_SOURCE: unique symbol;
4
3
  export type WritableStateSource<State extends object> = {
5
- [STATE_SOURCE]: WritableSignal<State>;
4
+ [STATE_SOURCE]: {
5
+ [K in keyof State]: WritableSignal<State[K]>;
6
+ };
6
7
  };
7
8
  export type StateSource<State extends object> = {
8
- [STATE_SOURCE]: Signal<State>;
9
+ [STATE_SOURCE]: {
10
+ [K in keyof State]: Signal<State[K]>;
11
+ };
9
12
  };
10
13
  export type PartialStateUpdater<State extends object> = (state: State) => Partial<State>;
11
14
  export type StateWatcher<State extends object> = (state: NoInfer<State>) => void;
15
+ export declare function isWritableSignal(value: unknown): value is WritableSignal<unknown>;
12
16
  export declare function isWritableStateSource<State extends object>(stateSource: StateSource<State>): stateSource is WritableStateSource<State>;
13
- export declare function patchState<State extends object>(stateSource: WritableStateSource<State>, ...updaters: Array<Partial<Prettify<State>> | PartialStateUpdater<Prettify<State>>>): void;
17
+ export declare function patchState<State extends object>(stateSource: WritableStateSource<State>, ...updaters: Array<Partial<NoInfer<State>> | PartialStateUpdater<NoInfer<State>>>): void;
14
18
  export declare function getState<State extends object>(stateSource: StateSource<State>): State;
15
19
  export declare function watchState<State extends object>(stateSource: StateSource<State>, watcher: StateWatcher<State>, config?: {
16
20
  injector?: Injector;
@@ -3,7 +3,7 @@ export type Prettify<T> = {
3
3
  [K in keyof T]: T[K];
4
4
  } & {};
5
5
  export type IsRecord<T> = T extends object ? T extends NonRecord ? false : true : false;
6
- export type IsUnknownRecord<T> = string extends keyof T ? true : number extends keyof T ? true : false;
6
+ export type IsUnknownRecord<T> = keyof T extends never ? true : string extends keyof T ? true : symbol extends keyof T ? true : number extends keyof T ? true : false;
7
7
  export type IsKnownRecord<T> = IsRecord<T> extends true ? IsUnknownRecord<T> extends true ? false : true : false;
8
8
  export type OmitPrivate<T> = {
9
9
  [K in keyof T as K extends `_${string}` ? never : K]: T[K];
@@ -1,7 +1,12 @@
1
- import { SignalsDictionary, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
1
+ import { Signal } from '@angular/core';
2
+ import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
2
3
  import { Prettify } from './ts-helpers';
3
- export declare function withComputed<Input extends SignalStoreFeatureResult, ComputedSignals extends SignalsDictionary>(signalsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props']>) => ComputedSignals): SignalStoreFeature<Input, {
4
+ type ComputedResult<ComputedDictionary extends Record<string | symbol, Signal<unknown> | (() => unknown)>> = {
5
+ [P in keyof ComputedDictionary]: ComputedDictionary[P] extends Signal<unknown> ? ComputedDictionary[P] : ComputedDictionary[P] extends () => infer V ? Signal<V> : never;
6
+ };
7
+ export declare function withComputed<Input extends SignalStoreFeatureResult, ComputedDictionary extends Record<string | symbol, Signal<unknown> | (() => unknown)>>(computedFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods']>) => ComputedDictionary): SignalStoreFeature<Input, {
4
8
  state: {};
5
- props: ComputedSignals;
9
+ props: ComputedResult<ComputedDictionary>;
6
10
  methods: {};
7
11
  }>;
12
+ export {};
@@ -23,4 +23,4 @@ import { Prettify } from './ts-helpers';
23
23
  *
24
24
  * @param featureFactory function returning the actual feature
25
25
  */
26
- export declare function withFeature<Input extends SignalStoreFeatureResult, Output extends SignalStoreFeatureResult>(featureFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => SignalStoreFeature<Input, Output>): SignalStoreFeature<Input, Output>;
26
+ export declare function withFeature<Input extends SignalStoreFeatureResult, Output extends SignalStoreFeatureResult>(featureFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Input['state']>>) => SignalStoreFeature<Input, Output>): SignalStoreFeature<Input, Output>;
@@ -1,8 +1,8 @@
1
1
  import { WritableStateSource } from './state-source';
2
2
  import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
3
  import { Prettify } from './ts-helpers';
4
- type HookFn<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => void;
5
- type HooksFactory<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => {
4
+ type HookFn<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Input['state']>>) => void;
5
+ type HooksFactory<Input extends SignalStoreFeatureResult> = (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Input['state']>>) => {
6
6
  onInit?: () => void;
7
7
  onDestroy?: () => void;
8
8
  };
@@ -0,0 +1,52 @@
1
+ import { WritableSignal } from '@angular/core';
2
+ import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
+ import { Prettify } from './ts-helpers';
4
+ type LinkedStateResult<LinkedStateInput extends Record<string | symbol, WritableSignal<unknown> | (() => unknown)>> = {
5
+ [K in keyof LinkedStateInput]: LinkedStateInput[K] extends WritableSignal<infer V> ? V : LinkedStateInput[K] extends () => infer V ? V : never;
6
+ };
7
+ /**
8
+ * @description
9
+ *
10
+ * Adds linked state slices to a SignalStore.
11
+ *
12
+ * @usageNotes
13
+ *
14
+ * ```typescript
15
+ * const OptionsStore = signalStore(
16
+ * withState({ options: [1, 2, 3] }),
17
+ * withLinkedState(({ options }) => ({
18
+ * selectedOption: () => options()[0],
19
+ * }))
20
+ * );
21
+ * ```
22
+ *
23
+ * This returns a state of type `{ options: number[], selectedOption: number | undefined }`.
24
+ * When the `options` signal changes, the `selectedOption` automatically updates.
25
+ *
26
+ * For advanced use cases, `linkedSignal` or any other `WritableSignal` instance can be used within `withLinkedState`:
27
+ *
28
+ * ```typescript
29
+ * type Option = { id: number; label: string };
30
+ *
31
+ * const OptionsStore = signalStore(
32
+ * withState({ options: [] as Option[] }),
33
+ * withLinkedState(({ options }) => ({
34
+ * selectedOption: linkedSignal<Option[], Option>({
35
+ * source: options,
36
+ * computation: (newOptions, previous) => {
37
+ * const option = newOptions.find((o) => o.id === previous?.value.id);
38
+ * return option ?? newOptions[0];
39
+ * },
40
+ * })
41
+ * }))
42
+ * )
43
+ * ```
44
+ *
45
+ * @param linkedStateFactory A function that returns an object literal with properties containing an actual `linkedSignal` or the computation function.
46
+ */
47
+ export declare function withLinkedState<State extends Record<string | symbol, WritableSignal<unknown> | (() => unknown)>, Input extends SignalStoreFeatureResult>(linkedStateFactory: (store: Prettify<StateSignals<Input['state']> & Input['props']>) => State): SignalStoreFeature<Input, {
48
+ state: LinkedStateResult<State>;
49
+ props: {};
50
+ methods: {};
51
+ }>;
52
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { WritableStateSource } from './state-source';
2
2
  import { MethodsDictionary, SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
3
  import { Prettify } from './ts-helpers';
4
- export declare function withMethods<Input extends SignalStoreFeatureResult, Methods extends MethodsDictionary>(methodsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Methods): SignalStoreFeature<Input, {
4
+ export declare function withMethods<Input extends SignalStoreFeatureResult, Methods extends MethodsDictionary>(methodsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Input['state']>>) => Methods): SignalStoreFeature<Input, {
5
5
  state: {};
6
6
  props: {};
7
7
  methods: Methods;
@@ -1,7 +1,7 @@
1
1
  import { WritableStateSource } from './state-source';
2
2
  import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from './signal-store-models';
3
3
  import { Prettify } from './ts-helpers';
4
- export declare function withProps<Input extends SignalStoreFeatureResult, Props extends object>(propsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Prettify<Input['state']>>>) => Props): SignalStoreFeature<Input, {
4
+ export declare function withProps<Input extends SignalStoreFeatureResult, Props extends object>(propsFactory: (store: Prettify<StateSignals<Input['state']> & Input['props'] & Input['methods'] & WritableStateSource<Input['state']>>) => Props): SignalStoreFeature<Input, {
5
5
  state: {};
6
6
  props: Props;
7
7
  methods: {};