File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -379,4 +379,10 @@ describe('Store', () => {
379379 `[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "anyName" in store "main".`
380380 ) . toHaveBeenWarnedTimes ( 1 )
381381 } )
382+
383+ it ( 'throws an error if no store id is provided' , ( ) => {
384+ expect ( ( ) => defineStore ( { } as any ) ) . toThrowError (
385+ '[🍍]: defineStore must be passed an id string, either as its first argument or via the "id" option.'
386+ )
387+ } )
382388} )
Original file line number Diff line number Diff line change @@ -879,6 +879,12 @@ export function defineStore(
879879 } else {
880880 options = idOrOptions
881881 id = idOrOptions . id
882+
883+ if ( __DEV__ && typeof id !== 'string' ) {
884+ throw new Error (
885+ `[🍍]: "defineStore()" must be passed a store id as its first argument.`
886+ )
887+ }
882888 }
883889
884890 function useStore ( pinia ?: Pinia | null , hot ?: StoreGeneric ) : StoreGeneric {
You can’t perform that action at this time.
0 commit comments