From: Evan You Date: Tue, 2 May 2023 08:23:02 +0000 (+0800) Subject: chore: experimental warnings for reactive props destructure and defineModel X-Git-Tag: v3.3.0-beta.4~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d40d4a33803d6740c4af395a80d1d339eb58d7d6;p=thirdparty%2Fvuejs%2Fcore.git chore: experimental warnings for reactive props destructure and defineModel --- diff --git a/packages/compiler-sfc/src/script/defineModel.ts b/packages/compiler-sfc/src/script/defineModel.ts index 0584196707..2e7800aba4 100644 --- a/packages/compiler-sfc/src/script/defineModel.ts +++ b/packages/compiler-sfc/src/script/defineModel.ts @@ -9,6 +9,7 @@ import { unwrapTSNode } from './utils' import { BindingTypes } from '@vue/compiler-dom' +import { warnOnce } from '../warn' export const DEFINE_MODEL = 'defineModel' @@ -26,6 +27,14 @@ export function processDefineModel( if (!ctx.options.defineModel || !isCallOf(node, DEFINE_MODEL)) { return false } + + warnOnce( + `This project is using defineModel(), which is an experimental ` + + ` feature. It may receive breaking changes or be removed in the future, so ` + + `use at your own risk.\n` + + `To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/503.` + ) + ctx.hasDefineModelCall = true const type = diff --git a/packages/compiler-sfc/src/script/definePropsDestructure.ts b/packages/compiler-sfc/src/script/definePropsDestructure.ts index 9f693f8519..f735b324eb 100644 --- a/packages/compiler-sfc/src/script/definePropsDestructure.ts +++ b/packages/compiler-sfc/src/script/definePropsDestructure.ts @@ -21,6 +21,7 @@ import { genPropsAccessExp } from '@vue/shared' import { isCallOf, resolveObjectKey, unwrapTSNode } from './utils' import { ScriptCompileContext } from './context' import { DEFINE_PROPS } from './defineProps' +import { warnOnce } from '../warn' export function processPropsDestructure( ctx: ScriptCompileContext, @@ -30,6 +31,13 @@ export function processPropsDestructure( return } + warnOnce( + `This project is using reactive props destructure, which is an experimental ` + + ` feature. It may receive breaking changes or be removed in the future, so ` + + `use at your own risk.\n` + + `To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.` + ) + ctx.propsDestructureDecl = declId const registerBinding = (