Skip to content

Commit

Permalink
test: disallow
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Apr 4, 2023
1 parent 1df0818 commit 980842e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,48 @@ defineOptions({ name: 'FooApp' })
'[@vue/compiler-sfc] defineOptions() cannot accept type arguments'
)
})

it('should emit an error with declaring props/emits/slots/expose', () => {
expect(() =>
compile(`
<script setup>
defineOptions({ props: ['foo'] })
</script>
`)
).toThrowError(
'[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead'
)

expect(() =>
compile(`
<script setup>
defineOptions({ emits: ['update'] })
</script>
`)
).toThrowError(
'[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead'
)

expect(() =>
compile(`
<script setup>
defineOptions({ expose: ['foo'] })
</script>
`)
).toThrowError(
'[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead'
)

expect(() =>
compile(`
<script setup lang="ts">
defineOptions({ slots: Object })
</script>
`)
).toThrowError(
'[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead'
)
})
})

test('defineExpose()', () => {
Expand Down

0 comments on commit 980842e

Please sign in to comment.