@@ -11,7 +11,7 @@ import { writable } from 'svelte/store'
1111/**
1212 * @typedef {Object } SvelteToastCustomComponent
1313 * @property {SvelteComponent } src - custom Svelte Component
14- * @property {Object. <string, * > } [props] - props to pass into custom component
14+ * @property {Object<string,any > } [props] - props to pass into custom component
1515 * @property {string } [sendIdTo] - forward toast id to prop name
1616 */
1717
@@ -32,7 +32,7 @@ import { writable } from 'svelte/store'
3232 * @property {boolean } [dismissable] - allow dissmiss with close button
3333 * @property {boolean } [reversed] - display toasts in reverse order
3434 * @property {FlyParams } [intro] - toast intro fly animation settings
35- * @property {Object. <string, string|number> } [theme] - css var overrides
35+ * @property {Object<string,string|number> } [theme] - css var overrides
3636 * @property {string[] } [classes] - user-defined classes
3737 * @property {SvelteToastOnPopCallback } [onpop] - callback that runs on toast dismiss
3838 * @property {SvelteToastCustomComponent } [component] - send custom Svelte Component as a message
@@ -50,13 +50,13 @@ const defaults = {
5050 intro : { x : 256 }
5151}
5252
53- const createToast = ( ) => {
54- const { subscribe, update } = writable ( [ ] )
55- /** @type {Object. <string, SvelteToastOptions> } */
53+ function createToast ( ) {
54+ const { subscribe, update } = writable ( new Array ( ) )
55+ /** @type {Object<string,SvelteToastOptions> } */
5656 const options = { }
5757 let count = 0
5858
59- /** @param {* } obj */
59+ /** @param {any } obj */
6060 function _obj ( obj ) {
6161 return obj instanceof Object
6262 }
@@ -96,14 +96,15 @@ const createToast = () => {
9696 * - toast.pop(0) // remove all toasts
9797 * - toast.pop(id) // removes the toast with specified `id`
9898 * - toast.pop({ target: 'foo' }) // remove all toasts from target `foo`
99- * @param {(number|Object. <'target', string>) } [id]
99+ * @param {(number|Object<'target',string>) } [id]
100100 */
101101 function pop ( id ) {
102102 update ( ( n ) => {
103103 if ( ! n . length || id === 0 ) return [ ]
104104 // Filter function is deprecated; shim added for backward compatibility
105105 if ( typeof id === 'function' ) return n . filter ( ( i ) => id ( i ) )
106- if ( _obj ( id ) ) return n . filter ( ( i ) => i . target !== id . target )
106+ if ( _obj ( id ) )
107+ return n . filter ( /** @type {SvelteToastOptions[] } i */ ( i ) => i . target !== id . target )
107108 const found = id || Math . max ( ...n . map ( ( i ) => i . id ) )
108109 return n . filter ( ( i ) => i . id !== found )
109110 } )
@@ -115,7 +116,7 @@ const createToast = () => {
115116 * @param {SvelteToastOptions } [opts]
116117 */
117118 function set ( id , opts ) {
118- /** @type {object } */
119+ /** @type {any } */
119120 const param = _obj ( id ) ? id : { ...opts , id }
120121 update ( ( n ) => {
121122 const idx = n . findIndex ( ( i ) => i . id === param . id )
0 commit comments