Skip to content

Commit 05eb216

Browse files
committed
refactor(language-core): generate script sections sequentially
1 parent 7d642d1 commit 05eb216

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

packages/language-core/lib/codegen/script/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ function* generateWorker(
160160
});
161161
}
162162

163-
yield* generateSfcBlockSection(script, 0, exportDefault.start, codeFeatures.all);
163+
yield* generateSfcBlockSection(script, 0, expression.start, codeFeatures.all);
164+
yield exportExpression;
165+
yield endOfLine;
166+
yield* generateTemplate(options, ctx);
164167
yield* generateExportDeclareEqual(script);
165168
if (wrapLeft) {
166169
yield wrapLeft;
@@ -169,10 +172,6 @@ function* generateWorker(
169172
if (wrapRight) {
170173
yield wrapRight;
171174
}
172-
yield endOfLine;
173-
yield* generateTemplate(options, ctx);
174-
yield* generateSfcBlockSection(script, exportDefault.start, expression.start, codeFeatures.all);
175-
yield exportExpression;
176175
yield* generateSfcBlockSection(script, expression.end, script.content.length, codeFeatures.all);
177176
}
178177
else {

packages/tsc/tests/__snapshots__/dts.spec.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`vue-tsc-dts > Input: component-name-description/component.vue, Output: component-name-description/component.vue.d.ts 1`] = `
4-
"declare const __VLS_export: import("vue").DefineComponent2<{
4+
"/**
5+
* My awesome component description
6+
*/
7+
declare const _default: typeof __VLS_export;
8+
export default _default;
9+
declare const __VLS_export: import("vue").DefineComponent2<{
510
setup(): {};
611
data(): {};
712
props: {
@@ -30,11 +35,6 @@ exports[`vue-tsc-dts > Input: component-name-description/component.vue, Output:
3035
__typeEl: any;
3136
__defaults: unknown;
3237
}>;
33-
/**
34-
* My awesome component description
35-
*/
36-
declare const _default: typeof __VLS_export;
37-
export default _default;
3838
"
3939
`;
4040

@@ -525,7 +525,9 @@ export default _default;
525525
`;
526526
527527
exports[`vue-tsc-dts > Input: reference-type-props/component-js.vue, Output: reference-type-props/component-js.vue.d.ts 1`] = `
528-
"declare const __VLS_export: import("vue").DefineComponent2<{
528+
"declare const _default: typeof __VLS_export;
529+
export default _default;
530+
declare const __VLS_export: import("vue").DefineComponent2<{
529531
setup(): {};
530532
data(): {};
531533
props: {
@@ -569,8 +571,6 @@ exports[`vue-tsc-dts > Input: reference-type-props/component-js.vue, Output: ref
569571
__typeEl: any;
570572
__defaults: unknown;
571573
}>;
572-
declare const _default: typeof __VLS_export;
573-
export default _default;
574574
"
575575
`;
576576

0 commit comments

Comments
 (0)