@@ -3,8 +3,8 @@ import type {
33TBaseStateApiForBuilder ,
44TSelectorBuilder ,
55} from '../types/baseStore' ;
6- import type { StoreMutatorIdentifier } from 'zustand' ;
76import type { TState } from '../types/utils' ;
7+ import type { StoreMutatorIdentifier } from 'zustand' ;
88
99const identity = < T > ( arg :T ) => arg ;
1010
@@ -41,7 +41,7 @@ export const extendSelectors = <
4141get :( ( key :string , ...args :unknown [ ] ) => {
4242if ( key in selectors ) {
4343const selector = selectors [ key ] ;
44- return selector ( ...args ) ;
44+ return selector ?. ( ...args ) ;
4545}
4646
4747return baseGet ( key as keyof StateType ) ;
@@ -70,9 +70,7 @@ export const extendSelectors = <
7070'state' ,
7171( ) =>
7272selectorArg (
73- selectors [ key as keyof typeof selectors ] (
74- ...selectorArgs
75- )
73+ selectors [ key as keyof typeof selectors ] ( ...selectorArgs )
7674) ,
7775listener ,
7876optionsArg
@@ -91,10 +89,7 @@ export const extendSelectors = <
9189
9290if ( options ?. selectWithStore ) {
9391const selectWithStore = options . selectWithStore ;
94- ( extendedApi as any ) . useValue = (
95- key :string ,
96- ...args :unknown [ ]
97- ) => {
92+ ( extendedApi as any ) . useValue = ( key :string , ...args :unknown [ ] ) => {
9893if ( key in selectors ) {
9994const selector = selectors [ key ] ;
10095const maybeEqualityFn = args . at ( - 1 ) ;
@@ -103,7 +98,7 @@ export const extendSelectors = <
10398const selectorArgs = equalityFn ?args . slice ( 0 , - 1 ) :args ;
10499
105100return selectWithStore (
106- ( ) => selector ( ...selectorArgs ) ,
101+ ( ) => selector ?. ( ...selectorArgs ) ,
107102equalityFn as AnyFunction
108103) ;
109104}