]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compile-sfc): generate setup prop type format error (#4506)
authorwebfansplz <308241863@qq.com>
Sun, 5 Sep 2021 21:36:46 +0000 (05:36 +0800)
committerGitHub <noreply@github.com>
Sun, 5 Sep 2021 21:36:46 +0000 (17:36 -0400)
fix #4505

packages/compiler-sfc/__tests__/compileScript.spec.ts
packages/compiler-sfc/src/compileScript.ts

index e5c2f4ae75213798feff36f55970388730feb978..6360b63c25212afb687c4a4dafd3dd9d8df95143 100644 (file)
@@ -799,8 +799,8 @@ const emit = defineEmits(['a', 'b'])
       <script setup lang="ts">
       const props = withDefaults(defineProps<{
         foo?: string
-        bar?: number
-        baz: boolean
+        bar?: number;
+        baz: boolean;
         qux?(): number
       }>(), {
         foo: 'hi',
index 13f597cc148f01d2a48cb8d55458315915aa32be..13c2a49380372786468a9bd8db1a366713b9441a 100644 (file)
@@ -623,7 +623,8 @@ export function compileScript(
               ) +
               ', '
           } else {
-            res += scriptSetupSource.slice(m.start!, m.end!) + `, `
+            res +=
+              scriptSetupSource.slice(m.start!, m.typeAnnotation.end!) + `, `
           }
         }
       }