expect(() =>
compile(`<script setup>
let bar = 1
- const model = defineModel({
+ defineModel({
default: () => bar
})
</script>`),
expect(() =>
compile(`<script setup>
const bar = 1
- const model = defineModel({
+ defineModel({
default: () => bar
})
</script>`),
expect(() =>
compile(`<script setup>
let bar = 1
- const model = defineModel({
+ defineModel({
get: () => bar,
set: () => bar
})
modelValue: BindingTypes.SETUP_REF,
})
})
-
- test('error when defineModel is not assigned to a variable', () => {
- expect(() =>
- compile(`
- <script setup>
- defineModel()
- </script>
- `),
- ).toThrow(
- 'defineModel() must be assigned to a variable. For example: const model = defineModel()',
- )
- })
})
return false
}
- if (!declId) {
- ctx.error(
- 'defineModel() must be assigned to a variable. For example: const model = defineModel()',
- node,
- )
- }
-
ctx.hasDefineModelCall = true
const type =