Skip to content

Commit 980842e

Browse files
committed
test: disallow
1 parent 1df0818 commit 980842e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/compiler-sfc/__tests__/compileScript.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,48 @@ defineOptions({ name: 'FooApp' })
262262
'[@vue/compiler-sfc] defineOptions() cannot accept type arguments'
263263
)
264264
})
265+
266+
it('should emit an error with declaring props/emits/slots/expose', () => {
267+
expect(() =>
268+
compile(`
269+
<script setup>
270+
defineOptions({ props: ['foo'] })
271+
</script>
272+
`)
273+
).toThrowError(
274+
'[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead'
275+
)
276+
277+
expect(() =>
278+
compile(`
279+
<script setup>
280+
defineOptions({ emits: ['update'] })
281+
</script>
282+
`)
283+
).toThrowError(
284+
'[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead'
285+
)
286+
287+
expect(() =>
288+
compile(`
289+
<script setup>
290+
defineOptions({ expose: ['foo'] })
291+
</script>
292+
`)
293+
).toThrowError(
294+
'[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead'
295+
)
296+
297+
expect(() =>
298+
compile(`
299+
<script setup lang="ts">
300+
defineOptions({ slots: Object })
301+
</script>
302+
`)
303+
).toThrowError(
304+
'[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead'
305+
)
306+
})
265307
})
266308

267309
test('defineExpose()', () => {

0 commit comments

Comments
 (0)