@@ -32,8 +32,15 @@ const Component = defineComponent({
3232 emits : [ 'update:modelValue' ] ,
3333 expose : [ 'method' ] ,
3434 setup : ( ) => {
35+ const message = ref ( 'message' )
36+ const number = ref ( 0 )
37+ const object = ref ( { a : 1 , b : new Date ( ) , c : true as boolean | undefined } )
3538 return {
36- method : ( ) => '' ,
39+ message,
40+ number,
41+ object,
42+ method : ( ) => message . value ,
43+ method2 : ( v : number ) => number . value + v ,
3744 }
3845 } ,
3946} )
@@ -44,13 +51,39 @@ type SuspendedAdditionalOptions = {
4451 scoped ?: boolean
4552}
4653
54+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55+ type AnySetupState = Record < string , any >
56+
4757type SuspendedAdditionalResult = {
48- // eslint-disable-next-line @typescript-eslint/no-explicit-any
49- setupState : Record < string , any >
58+ setupState : {
59+ message : Ref < string >
60+ number : Ref < number >
61+ object : Ref < { a : number , b : Date , c : boolean | undefined } >
62+ method : ( ) => string
63+ method2 : ( v : number ) => number
64+ } & AnySetupState
5065}
5166
5267type ComponentType = typeof Component
5368
69+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
70+ const AsyncSetupComponent = defineComponent ( {
71+ async setup ( ) {
72+ const message = ref ( 'message' )
73+ await Promise . resolve ( )
74+ return {
75+ message,
76+ method : ( ) => message . value ,
77+ }
78+ } ,
79+ } )
80+
81+ type AsyncSetupComponentType = typeof AsyncSetupComponent
82+ type AsyncSetupState = {
83+ message : Ref < string >
84+ method : ( ) => string
85+ } & AnySetupState
86+
5487describe ( 'mountSuspended' , ( ) => {
5588 describe ( 'options' , ( ) => {
5689 type Options = NonNullable < Parameters < typeof mountSuspended < ComponentType > > [ 1 ] >
@@ -88,6 +121,11 @@ describe('mountSuspended', () => {
88121 expectTypeOf < Pick < Result , keyof VueWrapper > > ( )
89122 . toEqualTypeOf < Pick < VueWrapper , keyof VueWrapper > > ( )
90123 } )
124+
125+ it ( 'has async setup setupState' , ( ) => {
126+ type AsyncResult = Awaited < ReturnType < typeof mountSuspended < AsyncSetupComponentType > > >
127+ expectTypeOf < AsyncResult [ 'setupState' ] > ( ) . toEqualTypeOf < AsyncSetupState > ( )
128+ } )
91129 } )
92130} )
93131
@@ -129,6 +167,11 @@ describe('renderSuspended', () => {
129167 expectTypeOf < Pick < Result , keyof RenderResult > > ( )
130168 . toEqualTypeOf < Pick < RenderResult , keyof RenderResult > > ( )
131169 } )
170+
171+ it ( 'has async setup setupState' , ( ) => {
172+ type AsyncResult = Awaited < ReturnType < typeof renderSuspended < AsyncSetupComponentType > > >
173+ expectTypeOf < AsyncResult [ 'setupState' ] > ( ) . toEqualTypeOf < AsyncSetupState > ( )
174+ } )
132175 } )
133176} )
134177
@@ -179,6 +222,11 @@ describe('browser.render', () => {
179222 expectTypeOf < Pick < Result , keyof LocatorSelectors > > ( )
180223 . toEqualTypeOf < Pick < LocatorSelectors , keyof LocatorSelectors > > ( )
181224 } )
225+
226+ it ( 'has async setup setupState' , ( ) => {
227+ type AsyncResult = Awaited < ReturnType < typeof render < AsyncSetupComponentType > > >
228+ expectTypeOf < AsyncResult [ 'setupState' ] > ( ) . toEqualTypeOf < AsyncSetupState > ( )
229+ } )
182230 } )
183231
184232 describe ( 'browser.page' , ( ) => {
0 commit comments