Skip to content

Commit

Permalink
fix: top level await error in SFC if two script blocks are present
Browse files Browse the repository at this point in the history
close #2712
  • Loading branch information
johnsoncodehk committed Apr 25, 2023
1 parent 3b9f676 commit 987b2f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/script.ts
Expand Up @@ -421,7 +421,7 @@ export function generate(
if (!scriptRanges?.exportDefault) {
codes.push('export default ');
}
codes.push('(() => {\n');
codes.push('await (async () => {\n');
scriptSetupGeneratedOffset = generateSetupFunction(false, 'return', definePropMirrors);
codes.push(`})()`);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/vue-test-workspace/vue-tsc/#2712/main.vue
@@ -0,0 +1,12 @@
<script lang="ts">
export default {
inheritAttrs: true,
};
</script>

<script setup lang="ts">
async function foo() {
return "bar";
}
await foo();
</script>

0 comments on commit 987b2f3

Please sign in to comment.