File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -176,4 +176,18 @@ describe('defineModel()', () => {
176
176
optional : BindingTypes . SETUP_REF
177
177
} )
178
178
} )
179
+
180
+ test ( 'should warn when disabled' , ( ) => {
181
+ compile (
182
+ `
183
+ <script setup lang="ts">
184
+ const modelValue = defineModel<boolean>()
185
+ </script>
186
+ ` ,
187
+ { defineModel : false }
188
+ )
189
+ expect (
190
+ 'defineModel() is an experimental feature and disabled by default.'
191
+ ) . toHaveBeenWarned ( )
192
+ } )
179
193
} )
Original file line number Diff line number Diff line change 9
9
unwrapTSNode
10
10
} from './utils'
11
11
import { BindingTypes } from '@vue/compiler-dom'
12
- import { warnOnce } from '../warn'
12
+ import { warn , warnOnce } from '../warn'
13
13
14
14
export const DEFINE_MODEL = 'defineModel'
15
15
@@ -24,7 +24,15 @@ export function processDefineModel(
24
24
node : Node ,
25
25
declId ?: LVal
26
26
) : boolean {
27
- if ( ! ctx . options . defineModel || ! isCallOf ( node , DEFINE_MODEL ) ) {
27
+ if ( ! isCallOf ( node , DEFINE_MODEL ) ) {
28
+ return false
29
+ }
30
+
31
+ if ( ! ctx . options . defineModel ) {
32
+ warn (
33
+ `defineModel() is an experimental feature and disabled by default.\n` +
34
+ `To enable it, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
35
+ )
28
36
return false
29
37
}
30
38
You can’t perform that action at this time.
0 commit comments