From 8d28afc17c0ce217d72925dd0b8bfaa6db0a8b92 Mon Sep 17 00:00:00 2001 From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com> Date: Thu, 4 Jul 2024 20:25:07 +0800 Subject: [PATCH] feat(language-core): support Vue 3.5 (#4474) --- .../lib/codegen/script/component.ts | 109 +++++++++++------- .../lib/codegen/script/globalTypes.ts | 6 +- .../lib/codegen/script/scriptSetup.ts | 27 +++-- .../lib/parsers/scriptSetupRanges.ts | 12 +- pnpm-lock.yaml | 103 +++++++++++++++++ test-workspace/package.json | 3 +- test-workspace/tsc/vue3.5/components/main.vue | 80 +++++++++++++ .../components/script-setup-default-props.vue | 11 ++ .../vue3.5/components/script-setup-expose.vue | 11 ++ .../components/script-setup-generic.vue | 8 ++ .../components/script-setup-type-only.vue | 11 ++ .../tsc/vue3.5/components/script-setup.vue | 7 ++ .../tsc/vue3.5/defineModel/main.vue | 42 +++++++ .../tsc/vue3.5/defineModel/script-setup.vue | 30 +++++ .../tsc/vue3.5/defineProp_B/main.vue | 41 +++++++ .../defineProp_B/script-setup-generic.vue | 21 ++++ .../tsc/vue3.5/defineProp_B/script-setup.vue | 22 ++++ test-workspace/tsc/vue3.5/env.d.ts | 3 + test-workspace/tsc/vue3.5/tsconfig.json | 9 ++ test-workspace/tsc/vue3/#1855/child.vue | 2 +- 20 files changed, 497 insertions(+), 61 deletions(-) create mode 100644 test-workspace/tsc/vue3.5/components/main.vue create mode 100644 test-workspace/tsc/vue3.5/components/script-setup-default-props.vue create mode 100644 test-workspace/tsc/vue3.5/components/script-setup-expose.vue create mode 100644 test-workspace/tsc/vue3.5/components/script-setup-generic.vue create mode 100644 test-workspace/tsc/vue3.5/components/script-setup-type-only.vue create mode 100644 test-workspace/tsc/vue3.5/components/script-setup.vue create mode 100644 test-workspace/tsc/vue3.5/defineModel/main.vue create mode 100644 test-workspace/tsc/vue3.5/defineModel/script-setup.vue create mode 100644 test-workspace/tsc/vue3.5/defineProp_B/main.vue create mode 100644 test-workspace/tsc/vue3.5/defineProp_B/script-setup-generic.vue create mode 100644 test-workspace/tsc/vue3.5/defineProp_B/script-setup.vue create mode 100644 test-workspace/tsc/vue3.5/env.d.ts create mode 100644 test-workspace/tsc/vue3.5/tsconfig.json diff --git a/packages/language-core/lib/codegen/script/component.ts b/packages/language-core/lib/codegen/script/component.ts index e61c3ab84a..8e76cefc88 100644 --- a/packages/language-core/lib/codegen/script/component.ts +++ b/packages/language-core/lib/codegen/script/component.ts @@ -67,60 +67,85 @@ export function* generateScriptSetupOptions( scriptSetup: NonNullable, scriptSetupRanges: ScriptSetupRanges ): Generator { - const propsCodegens: (() => Generator)[] = []; + yield* generatePropsOption(options, ctx, scriptSetup, scriptSetupRanges); + yield* generateEmitsOption(options, scriptSetup, scriptSetupRanges); +} - if (ctx.generatedPropsType) { - propsCodegens.push(function* () { - yield `{} as `; - if (scriptSetupRanges.props.withDefaults?.arg) { - yield `${ctx.helperTypes.WithDefaults.name}<`; - } - yield `${ctx.helperTypes.TypePropsToOption.name}<`; - yield `__VLS_PublicProps>`; - if (scriptSetupRanges.props.withDefaults?.arg) { - yield `, typeof __VLS_withDefaultsArg>`; - } - }); - } - if (scriptSetupRanges.props.define?.arg) { - const { arg } = scriptSetupRanges.props.define; - propsCodegens.push(function* () { - yield generateSfcBlockSection(scriptSetup, arg.start, arg.end, codeFeatures.navigation); - }); +export function* generatePropsOption( + options: ScriptCodegenOptions, + ctx: ScriptCodegenContext, + scriptSetup: NonNullable, + scriptSetupRanges: ScriptSetupRanges +) { + if (options.vueCompilerOptions.target >= 3.5 && ctx.generatedPropsType) { + yield `__typeProps: {} as __VLS_PublicProps,${newLine}`; } + else { + const codegens: (() => Generator)[] = []; - if (propsCodegens.length === 1) { - yield `props: `; - for (const generate of propsCodegens) { - yield* generate(); + if (ctx.generatedPropsType) { + codegens.push(function* () { + yield `{} as `; + if (scriptSetupRanges.props.withDefaults?.arg) { + yield `${ctx.helperTypes.WithDefaults.name}<`; + } + yield `${ctx.helperTypes.TypePropsToOption.name}<`; + yield `__VLS_PublicProps>`; + if (scriptSetupRanges.props.withDefaults?.arg) { + yield `, typeof __VLS_withDefaultsArg>`; + } + }); } - yield `,${newLine}`; - } - else if (propsCodegens.length >= 2) { - yield `props: {${newLine}`; - for (const generate of propsCodegens) { - yield `...`; - yield* generate(); + if (scriptSetupRanges.props.define?.arg) { + const { arg } = scriptSetupRanges.props.define; + codegens.push(function* () { + yield generateSfcBlockSection(scriptSetup, arg.start, arg.end, codeFeatures.navigation); + }); + } + + if (codegens.length === 1) { + yield `props: `; + for (const generate of codegens) { + yield* generate(); + } yield `,${newLine}`; } - yield `},${newLine}`; + else if (codegens.length >= 2) { + yield `props: {${newLine}`; + for (const generate of codegens) { + yield `...`; + yield* generate(); + yield `,${newLine}`; + } + yield `},${newLine}`; + } + } +} + +export function* generateEmitsOption( + options: ScriptCodegenOptions, + scriptSetup: NonNullable, + scriptSetupRanges: ScriptSetupRanges +): Generator { + if (!scriptSetupRanges.emits.define && !scriptSetupRanges.defineProp.some(p => p.isModel)) { + return; } - if (scriptSetupRanges.defineProp.filter(p => p.isModel).length || scriptSetupRanges.emits.define) { - yield `emits: ({} as __VLS_NormalizeEmits),${newLine}`; } - - if (options.vueCompilerOptions.target >= 3.5) { - // https://github.com/vuejs/core/pull/10801 - if (scriptSetupRanges.props.define?.typeArg) { - yield `__typeProps: __VLS_typeProps,${newLine}`; - } - if (scriptSetupRanges.emits.define?.typeArg) { - yield `__typeEmits: ${scriptSetupRanges.emits.name ?? '__VLS_emit'},${newLine}`; + else { + yield `__typeEmits: {} as __VLS_ModelEmitsType`; + const typeArg = scriptSetupRanges.emits.define?.typeArg; + if (typeArg) { + yield ` & `; + yield scriptSetup.content.slice(typeArg.start, typeArg.end); } + yield `,${newLine}`; } } diff --git a/packages/language-core/lib/codegen/script/globalTypes.ts b/packages/language-core/lib/codegen/script/globalTypes.ts index d58bce9cdf..0c3dbc21ea 100644 --- a/packages/language-core/lib/codegen/script/globalTypes.ts +++ b/packages/language-core/lib/codegen/script/globalTypes.ts @@ -16,8 +16,10 @@ declare global { ? `import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element;` : `globalThis.JSX.Element;` } - type __VLS_GlobalComponents = import('${vueCompilerOptions.lib}').GlobalComponents - & Pick; + type __VLS_GlobalComponents = ${vueCompilerOptions.target >= 3.5 + ? `import('${vueCompilerOptions.lib}').GlobalComponents` + : `import('${vueCompilerOptions.lib}').GlobalComponents & Pick;` + } type __VLS_BuiltInPublicProps = ${vueCompilerOptions.target >= 3.4 ? `import('${vueCompilerOptions.lib}').PublicProps;` : vueCompilerOptions.target >= 3.0 diff --git a/packages/language-core/lib/codegen/script/scriptSetup.ts b/packages/language-core/lib/codegen/script/scriptSetup.ts index 7ddaf4f5c0..2a7587d776 100644 --- a/packages/language-core/lib/codegen/script/scriptSetup.ts +++ b/packages/language-core/lib/codegen/script/scriptSetup.ts @@ -1,7 +1,7 @@ import type { ScriptSetupRanges } from '../../parsers/scriptSetupRanges'; import type { Code, Sfc } from '../../types'; import { endOfLine, generateSfcBlockSection, newLine } from '../common'; -import { generateComponent } from './component'; +import { generateComponent, generateEmitsOption } from './component'; import type { ScriptCodegenContext } from './context'; import { ScriptCodegenOptions, codeFeatures } from './index'; import { generateTemplate } from './template'; @@ -48,7 +48,7 @@ export function* generateScriptSetup( + ` __VLS_setup = (async () => {${newLine}`; yield* generateSetupFunction(options, ctx, scriptSetup, scriptSetupRanges, undefined, definePropMirrors); - const emitTypes = ['typeof __VLS_modelEmitsType']; + const emitTypes = ['__VLS_ModelEmitsType']; if (scriptSetupRanges.emits.define) { emitTypes.unshift(`typeof ${scriptSetupRanges.emits.name ?? '__VLS_emit'}`); @@ -265,14 +265,7 @@ function* generateComponentProps( yield generateSfcBlockSection(scriptSetup, scriptSetupRanges.props.define.arg.start, scriptSetupRanges.props.define.arg.end, codeFeatures.navigation); yield `,${newLine}`; } - if (scriptSetupRanges.emits.define || scriptSetupRanges.defineProp.some(p => p.isModel)) { - yield ` emits: ({} as __VLS_NormalizeEmits),${newLine}`; - } + yield* generateEmitsOption(options, scriptSetup, scriptSetupRanges); yield `})${endOfLine}`; yield `let __VLS_functionalComponentProps!: `; yield `${ctx.helperTypes.OmitKeepDiscriminatedUnion.name}['$props'], keyof __VLS_BuiltInPublicProps>`; @@ -371,10 +364,13 @@ function* generateModelEmits( scriptSetup: NonNullable, scriptSetupRanges: ScriptSetupRanges ): Generator { - yield `const __VLS_modelEmitsType = `; - + yield `type __VLS_ModelEmitsType = `; if (scriptSetupRanges.defineProp.filter(p => p.isModel).length) { - yield `(await import('${options.vueCompilerOptions.lib}')).defineEmits<{${newLine}`; + if (options.vueCompilerOptions.target < 3.5) { + yield `typeof __VLS_modelEmitsType${endOfLine}`; + yield `const __VLS_modelEmitsType = (await import('${options.vueCompilerOptions.lib}')).defineEmits<`; + } + yield `{${newLine}`; for (const defineProp of scriptSetupRanges.defineProp) { if (!defineProp.isModel) { continue; @@ -394,7 +390,10 @@ function* generateModelEmits( } yield `]${endOfLine}`; } - yield `}>()`; + yield `}`; + if (options.vueCompilerOptions.target < 3.5) { + yield `>()`; + } } else { yield `{}`; } diff --git a/packages/language-core/lib/parsers/scriptSetupRanges.ts b/packages/language-core/lib/parsers/scriptSetupRanges.ts index 7820557d55..a1caccbe1e 100644 --- a/packages/language-core/lib/parsers/scriptSetupRanges.ts +++ b/packages/language-core/lib/parsers/scriptSetupRanges.ts @@ -28,7 +28,9 @@ export function parseScriptSetupRanges( } = {}; const emits: { name?: string; - define?: ReturnType; + define?: ReturnType & { + hasUnionTypeArg?: boolean; + }; } = {}; const expose: { name?: string; @@ -216,6 +218,14 @@ export function parseScriptSetupRanges( if (ts.isVariableDeclaration(parent)) { emits.name = getNodeText(ts, parent.name, ast); } + if (node.typeArguments?.length && ts.isTypeLiteralNode(node.typeArguments[0]) && node.typeArguments[0].members.at(0)) { + for (const member of node.typeArguments[0].members) { + if (ts.isCallSignatureDeclaration(member) && member.parameters[0].type && ts.isUnionTypeNode(member.parameters[0].type)) { + emits.define.hasUnionTypeArg = true; + return; + } + } + } } else if (vueCompilerOptions.macros.defineExpose.includes(callText)) { expose.define = parseDefineFunction(node); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c77c241b56..acb123789a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -310,6 +310,9 @@ importers: vue3.3: specifier: npm:vue@3.3.13 version: vue@3.3.13(typescript@5.5.3) + vue3.5: + specifier: npm:vue@alpha + version: vue@3.5.0-alpha.2(typescript@5.5.3) packages: @@ -895,12 +898,18 @@ packages: '@vue/compiler-core@3.4.31': resolution: {integrity: sha512-skOiodXWTV3DxfDhB4rOf3OGalpITLlgCeOwb+Y9GJpfQ8ErigdBUHomBzvG78JoVE8MJoQsb+qhZiHfKeNeEg==} + '@vue/compiler-core@3.5.0-alpha.2': + resolution: {integrity: sha512-BWyn6mNsYytzNUJQdDXP4ftK/AjvD4+5bE7o08xQwsvbYnFwRF80Zi3G8LSe/0AiC68PLqz2iBqZQhdMfSGyww==} + '@vue/compiler-dom@3.3.13': resolution: {integrity: sha512-EYRDpbLadGtNL0Gph+HoKiYqXLqZ0xSSpR5Dvnu/Ep7ggaCbjRDIus1MMxTS2Qm0koXED4xSlvTZaTnI8cYAsw==} '@vue/compiler-dom@3.4.31': resolution: {integrity: sha512-wK424WMXsG1IGMyDGyLqB+TbmEBFM78hIsOJ9QwUVLGrcSk0ak6zYty7Pj8ftm7nEtdU/DGQxAXp0/lM/2cEpQ==} + '@vue/compiler-dom@3.5.0-alpha.2': + resolution: {integrity: sha512-2CoonkvK32tvz9n988sE3oXPoBKYtCO0jrjno9C4gemJ7g5q8D0VJyE5AzGYFKM8ZS7bjgp2T67PAmaOOgsu0Q==} + '@vue/compiler-sfc@2.7.16': resolution: {integrity: sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==} @@ -910,12 +919,18 @@ packages: '@vue/compiler-sfc@3.4.31': resolution: {integrity: sha512-einJxqEw8IIJxzmnxmJBuK2usI+lJonl53foq+9etB2HAzlPjAS/wa7r0uUpXw5ByX3/0uswVSrjNb17vJm1kQ==} + '@vue/compiler-sfc@3.5.0-alpha.2': + resolution: {integrity: sha512-tdTA3AseuL2PcT9xSEBr/3mRFiGEb8BMNydcNWgGwjQHUnVS/iJDkD3ob+QDTc4gdXENu0khQbrSb2cSvNXvTA==} + '@vue/compiler-ssr@3.3.13': resolution: {integrity: sha512-d/P3bCeUGmkJNS1QUZSAvoCIW4fkOKK3l2deE7zrp0ypJEy+En2AcypIkqvcFQOcw3F0zt2VfMvNsA9JmExTaw==} '@vue/compiler-ssr@3.4.31': resolution: {integrity: sha512-RtefmITAje3fJ8FSg1gwgDhdKhZVntIVbwupdyZDSifZTRMiWxWehAOTCc8/KZDnBOcYQ4/9VWxsTbd3wT0hAA==} + '@vue/compiler-ssr@3.5.0-alpha.2': + resolution: {integrity: sha512-wyjfDj3jHQI8Ad9cUWPml6dpO8cm3bsEdXOfiIsBSpDOKAlbdvBQIOpb9CQE09JLPK3j8hFtAEGPtq1COcL2kw==} + '@vue/reactivity-transform@3.3.13': resolution: {integrity: sha512-oWnydGH0bBauhXvh5KXUy61xr9gKaMbtsMHk40IK9M4gMuKPJ342tKFarY0eQ6jef8906m35q37wwA8DMZOm5Q==} @@ -925,18 +940,27 @@ packages: '@vue/reactivity@3.4.31': resolution: {integrity: sha512-VGkTani8SOoVkZNds1PfJ/T1SlAIOf8E58PGAhIOUDYPC4GAmFA2u/E14TDAFcf3vVDKunc4QqCe/SHr8xC65Q==} + '@vue/reactivity@3.5.0-alpha.2': + resolution: {integrity: sha512-4UG565XKudWMqijfrIY296XTJLBh3m/nZa+mLhsK5uMq0xBDFsJsrVskAmFlLNTlOd6c5FiktZufB9AB7m6VKw==} + '@vue/runtime-core@3.3.13': resolution: {integrity: sha512-1TzA5TvGuh2zUwMJgdfvrBABWZ7y8kBwBhm7BXk8rvdx2SsgcGfz2ruv2GzuGZNvL1aKnK8CQMV/jFOrxNQUMA==} '@vue/runtime-core@3.4.31': resolution: {integrity: sha512-LDkztxeUPazxG/p8c5JDDKPfkCDBkkiNLVNf7XZIUnJ+66GVGkP+TIh34+8LtPisZ+HMWl2zqhIw0xN5MwU1cw==} + '@vue/runtime-core@3.5.0-alpha.2': + resolution: {integrity: sha512-59R12UzEhqEOlItt6yKOoTyQ+Hx2hqFPKmdYPT9VAYmLH+ABngjrvw9KuJT9OsR+f4q/NwmCAAvjXV4gC56/cg==} + '@vue/runtime-dom@3.3.13': resolution: {integrity: sha512-JJkpE8R/hJKXqVTgUoODwS5wqKtOsmJPEqmp90PDVGygtJ4C0PtOkcEYXwhiVEmef6xeXcIlrT3Yo5aQ4qkHhQ==} '@vue/runtime-dom@3.4.31': resolution: {integrity: sha512-2Auws3mB7+lHhTFCg8E9ZWopA6Q6L455EcU7bzcQ4x6Dn4cCPuqj6S2oBZgN2a8vJRS/LSYYxwFFq2Hlx3Fsaw==} + '@vue/runtime-dom@3.5.0-alpha.2': + resolution: {integrity: sha512-3ShrCHo22tPMblLl0K6VXTv6MB95D9dBZH/YyJO+aLcOdEQXrLtVp8sXG6oPIwapBVlNkOZX7lUQbnzpdZgosQ==} + '@vue/server-renderer@3.3.13': resolution: {integrity: sha512-vSnN+nuf6iSqTL3Qgx/9A+BT+0Zf/VJOgF5uMZrKjYPs38GMYyAU1coDyBNHauehXDaP+zl73VhwWv0vBRBHcg==} peerDependencies: @@ -947,12 +971,20 @@ packages: peerDependencies: vue: 3.4.31 + '@vue/server-renderer@3.5.0-alpha.2': + resolution: {integrity: sha512-I9Mq56+B3XUhcKSEr0T9xTqOy04ORTrFANazPR871ITXAHO5viQXrdqOgh2nvBrz6L5c8vpDZgKDhKn+H7G9jg==} + peerDependencies: + vue: 3.5.0-alpha.2 + '@vue/shared@3.3.13': resolution: {integrity: sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA==} '@vue/shared@3.4.31': resolution: {integrity: sha512-Yp3wtJk//8cO4NItOPpi3QkLExAr/aLBGZMmTtW9WpdwBCJpRM6zj9WgWktXAl8IDIozwNMByT45JP3tO3ACWA==} + '@vue/shared@3.5.0-alpha.2': + resolution: {integrity: sha512-PMOD/qZfwNGE1xpz92Q7YtcGzz2JtvULSb4HIvv3N0idMAlIKmnzkIvsB0EhosPnJWe5O+xDe+DKmr6fIKu7HQ==} + JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -2997,6 +3029,14 @@ packages: typescript: optional: true + vue@3.5.0-alpha.2: + resolution: {integrity: sha512-dyhWA95ko++OlThqFNptBXiVFihKPfZ2487FKSYiB1X7LK1DX6AOjEfxbJdzupoNSOuHDVJIzOvcrBeyChX4vA==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} @@ -3782,6 +3822,14 @@ snapshots: estree-walker: 2.0.2 source-map-js: 1.2.0 + '@vue/compiler-core@3.5.0-alpha.2': + dependencies: + '@babel/parser': 7.24.7 + '@vue/shared': 3.5.0-alpha.2 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.0 + '@vue/compiler-dom@3.3.13': dependencies: '@vue/compiler-core': 3.3.13 @@ -3792,6 +3840,11 @@ snapshots: '@vue/compiler-core': 3.4.31 '@vue/shared': 3.4.31 + '@vue/compiler-dom@3.5.0-alpha.2': + dependencies: + '@vue/compiler-core': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + '@vue/compiler-sfc@2.7.16': dependencies: '@babel/parser': 7.24.7 @@ -3825,6 +3878,18 @@ snapshots: postcss: 8.4.39 source-map-js: 1.2.0 + '@vue/compiler-sfc@3.5.0-alpha.2': + dependencies: + '@babel/parser': 7.24.7 + '@vue/compiler-core': 3.5.0-alpha.2 + '@vue/compiler-dom': 3.5.0-alpha.2 + '@vue/compiler-ssr': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + estree-walker: 2.0.2 + magic-string: 0.30.10 + postcss: 8.4.39 + source-map-js: 1.2.0 + '@vue/compiler-ssr@3.3.13': dependencies: '@vue/compiler-dom': 3.3.13 @@ -3835,6 +3900,11 @@ snapshots: '@vue/compiler-dom': 3.4.31 '@vue/shared': 3.4.31 + '@vue/compiler-ssr@3.5.0-alpha.2': + dependencies: + '@vue/compiler-dom': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + '@vue/reactivity-transform@3.3.13': dependencies: '@babel/parser': 7.24.7 @@ -3851,6 +3921,10 @@ snapshots: dependencies: '@vue/shared': 3.4.31 + '@vue/reactivity@3.5.0-alpha.2': + dependencies: + '@vue/shared': 3.5.0-alpha.2 + '@vue/runtime-core@3.3.13': dependencies: '@vue/reactivity': 3.3.13 @@ -3861,6 +3935,11 @@ snapshots: '@vue/reactivity': 3.4.31 '@vue/shared': 3.4.31 + '@vue/runtime-core@3.5.0-alpha.2': + dependencies: + '@vue/reactivity': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + '@vue/runtime-dom@3.3.13': dependencies: '@vue/runtime-core': 3.3.13 @@ -3874,6 +3953,12 @@ snapshots: '@vue/shared': 3.4.31 csstype: 3.1.3 + '@vue/runtime-dom@3.5.0-alpha.2': + dependencies: + '@vue/runtime-core': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + csstype: 3.1.3 + '@vue/server-renderer@3.3.13(vue@3.4.31(typescript@5.5.3))': dependencies: '@vue/compiler-ssr': 3.3.13 @@ -3886,10 +3971,18 @@ snapshots: '@vue/shared': 3.4.31 vue: 3.4.31(typescript@5.5.3) + '@vue/server-renderer@3.5.0-alpha.2(vue@3.4.31(typescript@5.5.3))': + dependencies: + '@vue/compiler-ssr': 3.5.0-alpha.2 + '@vue/shared': 3.5.0-alpha.2 + vue: 3.4.31(typescript@5.5.3) + '@vue/shared@3.3.13': {} '@vue/shared@3.4.31': {} + '@vue/shared@3.5.0-alpha.2': {} + JSONStream@1.3.5: dependencies: jsonparse: 1.3.1 @@ -6034,6 +6127,16 @@ snapshots: optionalDependencies: typescript: 5.5.3 + vue@3.5.0-alpha.2(typescript@5.5.3): + dependencies: + '@vue/compiler-dom': 3.5.0-alpha.2 + '@vue/compiler-sfc': 3.5.0-alpha.2 + '@vue/runtime-dom': 3.5.0-alpha.2 + '@vue/server-renderer': 3.5.0-alpha.2(vue@3.4.31(typescript@5.5.3)) + '@vue/shared': 3.5.0-alpha.2 + optionalDependencies: + typescript: 5.5.3 + wcwidth@1.0.1: dependencies: defaults: 1.0.4 diff --git a/test-workspace/package.json b/test-workspace/package.json index e2a6d47230..0860517517 100644 --- a/test-workspace/package.json +++ b/test-workspace/package.json @@ -5,6 +5,7 @@ "vue": "^3.4.0", "vue-component-type-helpers": "2.0.26-alpha.2", "vue2": "npm:vue@2.7.16", - "vue3.3": "npm:vue@3.3.13" + "vue3.3": "npm:vue@3.3.13", + "vue3.5": "npm:vue@alpha" } } diff --git a/test-workspace/tsc/vue3.5/components/main.vue b/test-workspace/tsc/vue3.5/components/main.vue new file mode 100644 index 0000000000..ab5fdd188e --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/main.vue @@ -0,0 +1,80 @@ + diff --git a/test-workspace/tsc/vue3.5/components/script-setup-default-props.vue b/test-workspace/tsc/vue3.5/components/script-setup-default-props.vue new file mode 100644 index 0000000000..5f7ea7aa4c --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/script-setup-default-props.vue @@ -0,0 +1,11 @@ + diff --git a/test-workspace/tsc/vue3.5/components/script-setup-expose.vue b/test-workspace/tsc/vue3.5/components/script-setup-expose.vue new file mode 100644 index 0000000000..0186f94f29 --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/script-setup-expose.vue @@ -0,0 +1,11 @@ + diff --git a/test-workspace/tsc/vue3.5/components/script-setup-generic.vue b/test-workspace/tsc/vue3.5/components/script-setup-generic.vue new file mode 100644 index 0000000000..1de1c0a6fe --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/script-setup-generic.vue @@ -0,0 +1,8 @@ + diff --git a/test-workspace/tsc/vue3.5/components/script-setup-type-only.vue b/test-workspace/tsc/vue3.5/components/script-setup-type-only.vue new file mode 100644 index 0000000000..e1e2b57197 --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/script-setup-type-only.vue @@ -0,0 +1,11 @@ + diff --git a/test-workspace/tsc/vue3.5/components/script-setup.vue b/test-workspace/tsc/vue3.5/components/script-setup.vue new file mode 100644 index 0000000000..fdb37a19ec --- /dev/null +++ b/test-workspace/tsc/vue3.5/components/script-setup.vue @@ -0,0 +1,7 @@ + diff --git a/test-workspace/tsc/vue3.5/defineModel/main.vue b/test-workspace/tsc/vue3.5/defineModel/main.vue new file mode 100644 index 0000000000..22d1ff9e86 --- /dev/null +++ b/test-workspace/tsc/vue3.5/defineModel/main.vue @@ -0,0 +1,42 @@ + + + diff --git a/test-workspace/tsc/vue3.5/defineModel/script-setup.vue b/test-workspace/tsc/vue3.5/defineModel/script-setup.vue new file mode 100644 index 0000000000..d1a41272b6 --- /dev/null +++ b/test-workspace/tsc/vue3.5/defineModel/script-setup.vue @@ -0,0 +1,30 @@ + + + diff --git a/test-workspace/tsc/vue3.5/defineProp_B/main.vue b/test-workspace/tsc/vue3.5/defineProp_B/main.vue new file mode 100644 index 0000000000..80a05ed8ba --- /dev/null +++ b/test-workspace/tsc/vue3.5/defineProp_B/main.vue @@ -0,0 +1,41 @@ + diff --git a/test-workspace/tsc/vue3.5/defineProp_B/script-setup-generic.vue b/test-workspace/tsc/vue3.5/defineProp_B/script-setup-generic.vue new file mode 100644 index 0000000000..87f322d69d --- /dev/null +++ b/test-workspace/tsc/vue3.5/defineProp_B/script-setup-generic.vue @@ -0,0 +1,21 @@ + + + diff --git a/test-workspace/tsc/vue3.5/defineProp_B/script-setup.vue b/test-workspace/tsc/vue3.5/defineProp_B/script-setup.vue new file mode 100644 index 0000000000..1ee130a577 --- /dev/null +++ b/test-workspace/tsc/vue3.5/defineProp_B/script-setup.vue @@ -0,0 +1,22 @@ + + + diff --git a/test-workspace/tsc/vue3.5/env.d.ts b/test-workspace/tsc/vue3.5/env.d.ts new file mode 100644 index 0000000000..6920d23218 --- /dev/null +++ b/test-workspace/tsc/vue3.5/env.d.ts @@ -0,0 +1,3 @@ +declare module 'vue' { + export * from 'vue3.5'; +} diff --git a/test-workspace/tsc/vue3.5/tsconfig.json b/test-workspace/tsc/vue3.5/tsconfig.json new file mode 100644 index 0000000000..87f184a8cd --- /dev/null +++ b/test-workspace/tsc/vue3.5/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "vueCompilerOptions": { + "target": 3.5, + }, + "include": [ + "**/*" + ], +} diff --git a/test-workspace/tsc/vue3/#1855/child.vue b/test-workspace/tsc/vue3/#1855/child.vue index f679f09a0c..320cfdb7fa 100644 --- a/test-workspace/tsc/vue3/#1855/child.vue +++ b/test-workspace/tsc/vue3/#1855/child.vue @@ -1,5 +1,5 @@