From 1e6d640bf7ce0ca1d25e9cdbfb74f3d1872c769a Mon Sep 17 00:00:00 2001 From: Wilson Pinto Date: Mon, 5 Jun 2023 01:06:01 +0200 Subject: [PATCH] fix(schema): add types for vue experimental features (#21364) --- packages/schema/src/config/app.ts | 14 ++++++++++++++ packages/schema/src/config/vite.ts | 8 ++++++++ packages/schema/src/config/webpack.ts | 2 ++ 3 files changed, 24 insertions(+) diff --git a/packages/schema/src/config/app.ts b/packages/schema/src/config/app.ts index 357e937ad9..7bda98abf4 100644 --- a/packages/schema/src/config/app.ts +++ b/packages/schema/src/config/app.ts @@ -20,6 +20,20 @@ export default defineUntypedSchema({ runtimeCompiler: { $resolve: async (val, get) => val ?? await get('experimental.runtimeVueCompiler') ?? false, }, + + /** + * Vue Experimental: Enable reactive destructure for `defineProps` + * @see [Vue RFC#502](https://github.com/vuejs/rfcs/discussions/502) + * @type {boolean} + */ + propsDestructure: false, + + /** + * Vue Experimental: Enable macro `defineModel` + * @see [Vue RFC#503](https://github.com/vuejs/rfcs/discussions/503) + * @type {boolean} + */ + defineModel: false }, /** diff --git a/packages/schema/src/config/vite.ts b/packages/schema/src/config/vite.ts index 74ad62df50..5a6d07b44b 100644 --- a/packages/schema/src/config/vite.ts +++ b/packages/schema/src/config/vite.ts @@ -40,6 +40,14 @@ export default defineUntypedSchema({ compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue')).compilerOptions } + }, + script: { + propsDestructure: { + $resolve: async (val, get) => val ?? Boolean((await get('vue')).propsDestructure), + }, + defineModel: { + $resolve: async (val, get) => val ?? Boolean((await get('vue')).defineModel), + }, } }, vueJsx: { diff --git a/packages/schema/src/config/webpack.ts b/packages/schema/src/config/webpack.ts index 00eac91973..ef3b0bb43e 100644 --- a/packages/schema/src/config/webpack.ts +++ b/packages/schema/src/config/webpack.ts @@ -164,6 +164,8 @@ export default defineUntypedSchema({ embed: 'src' }, compilerOptions: { $resolve: async (val, get) => val ?? (await get('vue.compilerOptions')) }, + propsDestructure: { $resolve: async (val, get) => val ?? Boolean(await get('vue.propsDestructure')) }, + defineModel: { $resolve: async (val, get) => val ?? Boolean(await get('vue.defineModel')) }, }, css: { importLoaders: 0,