Skip to content

fix(language-core): use keywords instead of semicolons to separate script sections #5217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: generic wrapping
  • Loading branch information
KazariEX committed Feb 27, 2025
commit e4309fdae3c40415872fabdd155ff1375b8f94f2
3 changes: 0 additions & 3 deletions packages/language-core/lib/codegen/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
if (options.sfc.script) {
yield* generateScriptSectionPartiallyEnding(options.sfc.script.name, options.sfc.script.content.length, '#3632/script.vue');
}
if (options.sfc.scriptSetup) {
yield* generateScriptSectionPartiallyEnding(options.sfc.scriptSetup.name, options.sfc.scriptSetup.content.length, '#4569/main.vue');
}

if (!ctx.generatedTemplate) {
const templateCodegenCtx = yield* generateTemplate(options, ctx);
Expand Down
29 changes: 19 additions & 10 deletions packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ export function* generateScriptSetup(
): Generator<Code> {
if (scriptSetup.generic) {
if (!options.scriptRanges?.exportDefault) {
if (options.sfc.scriptSetup) {
// #4569
yield [
'',
'scriptSetup',
options.sfc.scriptSetup.content.length,
codeFeatures.verification,
];
}
// #4569
yield [
'',
'scriptSetup',
scriptSetup.content.length,
codeFeatures.verification,
];
yield `export default `;
}
yield `(`;
Expand Down Expand Up @@ -80,7 +78,18 @@ export function* generateScriptSetup(
+ ` emit: ${emitTypes.length ? emitTypes.join(' & ') : `{}`},${newLine}`
+ `}${endOfLine}`;
yield `})(),${newLine}`; // __VLS_setup = (async () => {
yield `) => ({} as import('${options.vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof __VLS_setup> }))`;
yield `) => ({} as import('${options.vueCompilerOptions.lib}').VNode & { __ctx?: Awaited<typeof __VLS_setup> }));`;

if (!options.scriptRanges?.exportDefault) {
// #4569
yield [
'',
'scriptSetup',
scriptSetup.content.length,
codeFeatures.verification,
];
}
yield newLine;
}
else if (!options.sfc.script) {
// no script block, generate script setup code at root
Expand Down