@@ -70,6 +70,35 @@ describe('defineVaporCustomElement using defineVaporComponent return type', () =
7070 expectType < number > ( instance . a )
7171 instance . a = 42
7272 } )
73+
74+ test ( 'with extra options' , ( ) => {
75+ const Comp1Vapor = defineVaporComponent ( {
76+ props : {
77+ a : {
78+ type : Number ,
79+ default : 1 ,
80+ validator : ( ) => true ,
81+ } ,
82+ } ,
83+ emits : [ 'click' ] ,
84+ } )
85+ const Comp = defineVaporCustomElement ( Comp1Vapor , {
86+ shadowRoot : false ,
87+ styles : [ `div { color: red; }` ] ,
88+ nonce : 'xxx' ,
89+ shadowRootOptions : {
90+ clonable : false ,
91+ } ,
92+ configureApp : app => {
93+ app . provide ( 'a' , 1 )
94+ } ,
95+ } )
96+ expectType < VaporElementConstructor > ( Comp )
97+
98+ const instance = new Comp ( )
99+ expectType < number > ( instance . a )
100+ instance . a = 42
101+ } )
73102} )
74103
75104describe ( 'defineVaporCustomElement with direct setup function' , ( ) => {
@@ -99,6 +128,33 @@ describe('defineVaporCustomElement with direct setup function', () => {
99128 const instance = new Comp ( )
100129 expectType < string > ( instance . msg )
101130 } )
131+
132+ test ( 'setup function with extra options' , ( ) => {
133+ const Comp = defineVaporCustomElement (
134+ ( props : { msg : string } , ctx ) => {
135+ ctx . emit ( 'foo' )
136+ return [ ]
137+ } ,
138+ {
139+ name : 'Foo' ,
140+ emits : [ 'foo' ] ,
141+ inheritAttrs : false ,
142+ shadowRoot : false ,
143+ styles : [ `div { color: red; }` ] ,
144+ nonce : 'xxx' ,
145+ shadowRootOptions : {
146+ clonable : false ,
147+ } ,
148+ configureApp : app => {
149+ app . provide ( 'a' , 1 )
150+ } ,
151+ } ,
152+ )
153+ expectType < VaporElementConstructor < { msg : string } > > ( Comp )
154+
155+ const instance = new Comp ( )
156+ expectType < string > ( instance . msg )
157+ } )
102158} )
103159
104160describe ( 'defineVaporCustomElement with options object' , ( ) => {
@@ -159,4 +215,34 @@ describe('defineVaporCustomElement with options object', () => {
159215 const instance = new Comp ( )
160216 expectType < string | undefined > ( instance . value )
161217 } )
218+
219+ test ( 'with extra options' , ( ) => {
220+ const Comp = defineVaporCustomElement (
221+ {
222+ props : {
223+ value : String ,
224+ } ,
225+ emits : {
226+ change : ( val : string ) => true ,
227+ } ,
228+ setup ( props , { emit } ) {
229+ emit ( 'change' , 'test' )
230+ // @ts -expect-error
231+ emit ( 'change' , 123 )
232+ // @ts -expect-error
233+ emit ( 'unknown' )
234+ } ,
235+ } ,
236+ {
237+ shadowRoot : false ,
238+ configureApp : app => {
239+ app . provide ( 'a' , 1 )
240+ } ,
241+ } ,
242+ )
243+ expectType < VaporElementConstructor > ( Comp )
244+
245+ const instance = new Comp ( )
246+ expectType < string | undefined > ( instance . value )
247+ } )
162248} )
0 commit comments