@@ -133,7 +133,7 @@ const myEmit = defineEmits(['foo', 'bar'])
133
133
expect ( bindings ) . toStrictEqual ( {
134
134
myEmit : BindingTypes . SETUP_CONST
135
135
} )
136
- // should remove defineOptions import and call
136
+ // should remove defineEmits import and call
137
137
expect ( content ) . not . toMatch ( 'defineEmits' )
138
138
// should generate correct setup signature
139
139
expect ( content ) . toMatch (
@@ -205,10 +205,10 @@ const myEmit = defineEmits(['foo', 'bar'])
205
205
describe ( 'defineOptions()' , ( ) => {
206
206
test ( 'basic usage' , ( ) => {
207
207
const { content } = compile ( `
208
- <script setup>
209
- defineOptions({ name: 'FooApp' })
210
- </script>
211
- ` )
208
+ <script setup>
209
+ defineOptions({ name: 'FooApp' })
210
+ </script>
211
+ ` )
212
212
assertCode ( content )
213
213
// should remove defineOptions import and call
214
214
expect ( content ) . not . toMatch ( 'defineOptions' )
@@ -218,6 +218,18 @@ defineOptions({ name: 'FooApp' })
218
218
)
219
219
} )
220
220
221
+ test ( 'empty argument' , ( ) => {
222
+ const { content } = compile ( `
223
+ <script setup>
224
+ defineOptions()
225
+ </script>
226
+ ` )
227
+ assertCode ( content )
228
+ expect ( content ) . toMatch ( `export default {` )
229
+ // should remove defineOptions import and call
230
+ expect ( content ) . not . toMatch ( 'defineOptions' )
231
+ } )
232
+
221
233
it ( 'should emit an error with two defineProps' , ( ) => {
222
234
expect ( ( ) =>
223
235
compile ( `
@@ -249,6 +261,26 @@ defineOptions({ name: 'FooApp' })
249
261
) . toThrowError (
250
262
'[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead.'
251
263
)
264
+
265
+ expect ( ( ) =>
266
+ compile ( `
267
+ <script setup>
268
+ defineOptions({ expose: ['foo'] })
269
+ </script>
270
+ ` )
271
+ ) . toThrowError (
272
+ '[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead.'
273
+ )
274
+
275
+ expect ( ( ) =>
276
+ compile ( `
277
+ <script setup>
278
+ defineOptions({ slots: ['foo'] })
279
+ </script>
280
+ ` )
281
+ ) . toThrowError (
282
+ '[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead.'
283
+ )
252
284
} )
253
285
254
286
it ( 'should emit an error with type generic' , ( ) => {
@@ -262,6 +294,18 @@ defineOptions({ name: 'FooApp' })
262
294
'[@vue/compiler-sfc] defineOptions() cannot accept type arguments'
263
295
)
264
296
} )
297
+
298
+ it ( 'should emit an error with type assertion' , ( ) => {
299
+ expect ( ( ) =>
300
+ compile ( `
301
+ <script setup lang="ts">
302
+ defineOptions({ props: [] } as any)
303
+ </script>
304
+ ` )
305
+ ) . toThrowError (
306
+ '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead.'
307
+ )
308
+ } )
265
309
} )
266
310
267
311
test ( 'defineExpose()' , ( ) => {
0 commit comments