@@ -7,7 +7,7 @@ import { StackItem } from './stack-item.svelte.js';
77 * @template {Record<string, import('svelte').Component>} [VariantMap={}]
88 */
99export class Stack {
10- /** @type {Record<string, import('./types.d.ts').StackItemVariantConfig<any, any, any >> } */
10+ /** @type {Record<string, import('./types.d.ts').StackItemVariantConfig<string, import('svelte').Component >> } */
1111 #variantConfigMap = { } ;
1212 #counter = 0 ;
1313
@@ -19,7 +19,7 @@ export class Stack {
1919 items = $state ( [ ] ) ;
2020
2121 /**
22- * @type {Required<import('./types.d.ts').StackItemCommonConfig<any, any, any >> }
22+ * @type {Required<import('./types.d.ts').StackItemCommonConfig<string, import('svelte').Component >> }
2323 */
2424 // eslint-disable-next-line no-undef
2525 config = $state ( {
@@ -48,8 +48,8 @@ export class Stack {
4848 } ;
4949
5050 /**
51- * @param {Record<keyof VariantMap, import('./types.d.ts').StackItemVariantConfig<any, any, any >> } variantConfigMap
52- * @param {import('./types.d.ts').StackItemCommonConfig<any, any, any > } [init]
51+ * @param {Record<keyof VariantMap, import('./types.d.ts').StackItemVariantConfig<string, import('svelte').Component >> } variantConfigMap
52+ * @param {import('./types.d.ts').StackItemCommonConfig<string, import('svelte').Component > } [init]
5353 */
5454 constructor ( variantConfigMap , init ) {
5555 if ( init ?. id ) this . config . id = init . id ;
@@ -61,35 +61,33 @@ export class Stack {
6161 /**
6262 * @template {Extract<keyof VariantMap, string>} Variant
6363 * @template {VariantMap[Variant]} [UserComponent=VariantMap[Variant]]
64- * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<UserComponent>['item']['resolution']>]
6564 * @overload
6665 * @param {Variant } variant
67- * @param {import('./types.d.ts').StackItemByVariantPushConfig<Resolved, Variant, UserComponent> } [config]
68- * @returns {StackItem<Resolved > }
66+ * @param {import('./types.d.ts').StackItemByVariantPushConfig<Variant, UserComponent> } [config]
67+ * @returns {StackItem<UserComponent > }
6968 */
7069 /**
7170 * @template {import('svelte').Component} UserComponent
72- * @template [Resolved=undefined|Awaited<import('svelte').ComponentProps<UserComponent>['item']['resolution']>]
7371 * @overload
7472 * @param {'custom' } variant
75- * @param {import('./types.d.ts').StackItemCustomPushConfig<Resolved, UserComponent> } config
76- * @returns {StackItem<Resolved > }
73+ * @param {import('./types.d.ts').StackItemCustomPushConfig<UserComponent> } config
74+ * @returns {StackItem<UserComponent > }
7775 */
7876 /**
7977 * @param {string } variant
80- * @param {import('./types.d.ts').StackItemByVariantPushConfig<any, string, import('svelte').Component> | import('./types.d.ts').StackItemCustomPushConfig<any, import('svelte').Component> } [config]
78+ * @param {import('./types.d.ts').StackItemByVariantPushConfig<string, import('svelte').Component> | import('./types.d.ts').StackItemCustomPushConfig<import('svelte').Component> } [config]
8179 * @returns {StackItem<any> }
8280 */
8381 push ( variant , config ) {
8482 // STEP 1: resolve instance config, merge with common config and variant config, if any
85- /** @type {import('./types.d.ts').StackItemInstanceConfig<any, any, any > } */
83+ /** @type {import('./types.d.ts').StackItemInstanceConfig<string, import('svelte').Component > } */
8684 let instanceConfig ;
87- /** @type {NonNullable<import('./types.d.ts').StackItemCommonConfig<Resolved, string, import('svelte').Component>['id']> } */
85+ /** @type {NonNullable<import('./types.d.ts').StackItemCommonConfig<string, import('svelte').Component>['id']> } */
8886 let idResolver ;
8987
9088 if ( variant === 'custom' ) {
9189 const rConfig =
92- /** @type {import('./types.d.ts').StackItemCustomPushConfig<any, any > } */ (
90+ /** @type {import('./types.d.ts').StackItemCustomPushConfig<import('svelte').Component > } */ (
9391 config
9492 ) ;
9593 if ( ! rConfig || ! rConfig . component ) {
@@ -151,21 +149,23 @@ export class Stack {
151149 }
152150
153151 /**
152+ * @template {import('svelte').Component} [UserComponent=import('svelte').Component]
154153 * @overload
155154 * @param {string } [id]
156155 * @param {any } [detail]
157- * @returns {void }
156+ * @returns {StackItem<UserComponent> | null }
158157 */
159158 /**
159+ * @template {import('svelte').Component} [UserComponent=import('svelte').Component]
160160 * @overload
161- * @param {import('./types.d.ts').StackItemPopVerboseInput } [config]
162- * @returns {void }
161+ * @param {import('./types.d.ts').StackItemPopVerboseInput<UserComponent> } [config]
162+ * @returns {StackItem<UserComponent> | null }
163163 */
164164 /**
165- *
166- * @param {string | import('./types.d.ts').StackItemPopVerboseInput } [config]
165+ * @template {import('svelte').Component} [UserComponent=import('svelte').Component]
166+ * @param {string | import('./types.d.ts').StackItemPopVerboseInput<UserComponent> } [config]
167167 * @param {any } [resolved]
168- * @returns {void }
168+ * @returns {StackItem<UserComponent> | null }
169169 */
170170 pop ( config , resolved ) {
171171 /** @type {string | undefined } */
@@ -179,18 +179,20 @@ export class Stack {
179179 }
180180 }
181181
182- /** @type {StackItem<any > | undefined } */
183- let pushed ;
182+ /** @type {StackItem<UserComponent > | null } */
183+ let pushed = null ;
184184 if ( id ) {
185- pushed = this . items . find ( ( n ) => n . config . id === id ) ;
185+ pushed = this . items . find ( ( n ) => n . config . id === id ) ?? null ;
186186 } else {
187- pushed = this . items . at ( - 1 ) ;
187+ pushed = this . items . at ( - 1 ) ?? null ;
188188 }
189189
190190 if ( pushed ) {
191191 pushed . resolve ( resolved ) ;
192192 this . items = this . items . filter ( ( n ) => n . config . id !== pushed . config . id ) ;
193193 }
194+
195+ return pushed ;
194196 }
195197
196198 /**
0 commit comments