Quellcode durchsuchen

fix(compile-sfc): generate setup prop type format error (#4506)

fix #4505
webfansplz vor 4 Jahren
Ursprung
Commit
e6fe751b20

+ 2 - 2
packages/compiler-sfc/__tests__/compileScript.spec.ts

@@ -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',

+ 2 - 1
packages/compiler-sfc/src/compileScript.ts

@@ -623,7 +623,8 @@ export function compileScript(
               ) +
               ', '
           } else {
-            res += scriptSetupSource.slice(m.start!, m.end!) + `, `
+            res +=
+              scriptSetupSource.slice(m.start!, m.typeAnnotation.end!) + `, `
           }
         }
       }