@@ -11,7 +11,7 @@ import { writable } from 'svelte/store'
11
11
/**
12
12
* @typedef {Object } SvelteToastCustomComponent
13
13
* @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
15
15
* @property {string } [sendIdTo] - forward toast id to prop name
16
16
*/
17
17
@@ -32,7 +32,7 @@ import { writable } from 'svelte/store'
32
32
* @property {boolean } [dismissable] - allow dissmiss with close button
33
33
* @property {boolean } [reversed] - display toasts in reverse order
34
34
* @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
36
36
* @property {string[] } [classes] - user-defined classes
37
37
* @property {SvelteToastOnPopCallback } [onpop] - callback that runs on toast dismiss
38
38
* @property {SvelteToastCustomComponent } [component] - send custom Svelte Component as a message
@@ -50,13 +50,13 @@ const defaults = {
50
50
intro : { x : 256 }
51
51
}
52
52
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> } */
56
56
const options = { }
57
57
let count = 0
58
58
59
- /** @param {* } obj */
59
+ /** @param {any } obj */
60
60
function _obj ( obj ) {
61
61
return obj instanceof Object
62
62
}
@@ -96,14 +96,15 @@ const createToast = () => {
96
96
* - toast.pop(0) // remove all toasts
97
97
* - toast.pop(id) // removes the toast with specified `id`
98
98
* - toast.pop({ target: 'foo' }) // remove all toasts from target `foo`
99
- * @param {(number|Object. <'target', string>) } [id]
99
+ * @param {(number|Object<'target',string>) } [id]
100
100
*/
101
101
function pop ( id ) {
102
102
update ( ( n ) => {
103
103
if ( ! n . length || id === 0 ) return [ ]
104
104
// Filter function is deprecated; shim added for backward compatibility
105
105
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 )
107
108
const found = id || Math . max ( ...n . map ( ( i ) => i . id ) )
108
109
return n . filter ( ( i ) => i . id !== found )
109
110
} )
@@ -115,7 +116,7 @@ const createToast = () => {
115
116
* @param {SvelteToastOptions } [opts]
116
117
*/
117
118
function set ( id , opts ) {
118
- /** @type {object } */
119
+ /** @type {any } */
119
120
const param = _obj ( id ) ? id : { ...opts , id }
120
121
update ( ( n ) => {
121
122
const idx = n . findIndex ( ( i ) => i . id === param . id )
0 commit comments