Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit f436b0d

Browse files
committed
fix: declaraion without initialization statement, close #46
1 parent f9cea2e commit f436b0d

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/core/transformScriptSetup.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ function isAsyncImport(node: any) {
1111
if (node.type === 'VariableDeclaration') {
1212
const declaration = node.declarations[0]
1313

14-
return declaration.init.callee != null
15-
&& declaration.init.callee.name === 'defineAsyncComponent'
14+
return declaration?.init?.callee?.name === 'defineAsyncComponent'
1615
}
1716

1817
return false

test/__snapshots__/transform.test.ts.snap

+5-1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ exports[`transform fixtures test/fixtures/RefSugar.vue 1`] = `
509509
<div>
510510
{{ msg }}
511511
{{ msg2 }}
512+
{{ a }}
512513
</div>
513514
</template>
514515
@@ -534,8 +535,11 @@ const __sfc_main = defineComponent({
534535
__sfc_main.setup = (__props, __ctx) => {
535536
let msg2 = _ref('hello world');
536537
538+
let a: number;
539+
a = 2;
537540
return {
538-
msg2
541+
msg2,
542+
a
539543
};
540544
};
541545

test/fixtures/RefSugar.vue

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div>
33
{{ msg }}
44
{{ msg2 }}
5+
{{ a }}
56
</div>
67
</template>
78

@@ -23,4 +24,8 @@ export default defineComponent({
2324

2425
<script setup lang="ts">
2526
let msg2 = $ref('hello world')
27+
28+
let a: number
29+
30+
a = 2
2631
</script>

0 commit comments

Comments
 (0)