Skip to content

Commit

Permalink
fix: allow using as with multiple <script> blocks (#3733)
Browse files Browse the repository at this point in the history
Co-authored-by: Johnson Chu <[email protected]>
  • Loading branch information
so1ve and johnsoncodehk authored Nov 29, 2023
1 parent 2107f39 commit 87473a9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
18 changes: 0 additions & 18 deletions packages/language-core/src/generators/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,6 @@ export function generate(
FileRangeCapabilities.full,
]);
}
function generateExportDefaultEndMapping() {
if (!scriptSetup) {
return;
}
// fix https://github.com/vuejs/language-tools/issues/1127
codes.push([
'',
'scriptSetup',
scriptSetup.content.length,
{ diagnostic: true },
]);
codes.push(`\n`);
}
function generateScriptSetupAndTemplate() {

if (!scriptSetup || !scriptSetupRanges) {
Expand Down Expand Up @@ -400,8 +387,6 @@ export function generate(
codes.push(`})()`);
}

generateExportDefaultEndMapping();

if (scriptSetupGeneratedOffset !== undefined) {
for (const defineProp of scriptSetupRanges.defineProp) {
if (!defineProp.name) {
Expand Down Expand Up @@ -580,9 +565,6 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
codes.push(`;\n`);
}
}
if (mode === 'export') {
generateExportDefaultEndMapping();
}

return scriptSetupGeneratedOffset;
}
Expand Down
5 changes: 5 additions & 0 deletions test-workspace/tsc/vue3/#3732/child.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts"></script>

<script lang="ts">
export default {} as any as 1;
</script>
5 changes: 5 additions & 0 deletions test-workspace/tsc/vue3/#3732/child2.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts"></script>

<script lang="ts">
export default ({}) as any as 1;
</script>
6 changes: 6 additions & 0 deletions test-workspace/tsc/vue3/#3732/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { exactType } from '../../shared';
import child from './child.vue';
import child2 from './child2.vue';

exactType(child, 1);
exactType(child2, 1);

0 comments on commit 87473a9

Please sign in to comment.