Revert "fix(compiler-sfc): add error handling for defineModel() without varia…" (#13390)
ci / test (push) Waiting to run Details
ci / continuous-release (push) Waiting to run Details
size data / upload (push) Waiting to run Details

This reverts commit 00734afef5.
This commit is contained in:
edison 2025-05-27 18:49:34 +08:00 committed by GitHub
parent d5ada3d235
commit 42f879fcab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 22 deletions

View File

@ -1007,7 +1007,7 @@ describe('SFC compile <script setup>', () => {
expect(() => expect(() =>
compile(`<script setup> compile(`<script setup>
let bar = 1 let bar = 1
const model = defineModel({ defineModel({
default: () => bar default: () => bar
}) })
</script>`), </script>`),
@ -1017,7 +1017,7 @@ describe('SFC compile <script setup>', () => {
expect(() => expect(() =>
compile(`<script setup> compile(`<script setup>
const bar = 1 const bar = 1
const model = defineModel({ defineModel({
default: () => bar default: () => bar
}) })
</script>`), </script>`),
@ -1027,7 +1027,7 @@ describe('SFC compile <script setup>', () => {
expect(() => expect(() =>
compile(`<script setup> compile(`<script setup>
let bar = 1 let bar = 1
const model = defineModel({ defineModel({
get: () => bar, get: () => bar,
set: () => bar set: () => bar
}) })

View File

@ -269,16 +269,4 @@ describe('defineModel()', () => {
modelValue: BindingTypes.SETUP_REF, 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()',
)
})
}) })

View File

@ -22,13 +22,6 @@ export function processDefineModel(
return false return false
} }
if (!declId) {
ctx.error(
'defineModel() must be assigned to a variable. For example: const model = defineModel()',
node,
)
}
ctx.hasDefineModelCall = true ctx.hasDefineModelCall = true
const type = const type =