Skip to content

Commit d40d4a3

Browse files
committed
chore: experimental warnings for reactive props destructure and defineModel
1 parent bff63c5 commit d40d4a3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/compiler-sfc/src/script/defineModel.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
unwrapTSNode
1010
} from './utils'
1111
import { BindingTypes } from '@vue/compiler-dom'
12+
import { warnOnce } from '../warn'
1213

1314
export const DEFINE_MODEL = 'defineModel'
1415

@@ -26,6 +27,14 @@ export function processDefineModel(
2627
if (!ctx.options.defineModel || !isCallOf(node, DEFINE_MODEL)) {
2728
return false
2829
}
30+
31+
warnOnce(
32+
`This project is using defineModel(), which is an experimental ` +
33+
` feature. It may receive breaking changes or be removed in the future, so ` +
34+
`use at your own risk.\n` +
35+
`To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.`
36+
)
37+
2938
ctx.hasDefineModelCall = true
3039

3140
const type =

packages/compiler-sfc/src/script/definePropsDestructure.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { genPropsAccessExp } from '@vue/shared'
2121
import { isCallOf, resolveObjectKey, unwrapTSNode } from './utils'
2222
import { ScriptCompileContext } from './context'
2323
import { DEFINE_PROPS } from './defineProps'
24+
import { warnOnce } from '../warn'
2425

2526
export function processPropsDestructure(
2627
ctx: ScriptCompileContext,
@@ -30,6 +31,13 @@ export function processPropsDestructure(
3031
return
3132
}
3233

34+
warnOnce(
35+
`This project is using reactive props destructure, which is an experimental ` +
36+
` feature. It may receive breaking changes or be removed in the future, so ` +
37+
`use at your own risk.\n` +
38+
`To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
39+
)
40+
3341
ctx.propsDestructureDecl = declId
3442

3543
const registerBinding = (

0 commit comments

Comments
 (0)