Skip to content

Commit

Permalink
fix(language-core): use defineEmits calls instead of type infer (vuej…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj authored and tl committed Jun 18, 2024
1 parent bd842da commit 8df7c3c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,10 @@ function* generateModelEmits(
scriptSetup: NonNullable<Sfc['scriptSetup']>,
scriptSetupRanges: ScriptSetupRanges,
): Generator<Code> {
yield `let __VLS_modelEmitsType!: {}`;
yield `const __VLS_modelEmitsType = `;

if (scriptSetupRanges.defineProp.length) {
yield ` & ReturnType<typeof import('${options.vueCompilerOptions.lib}').defineEmits<{${newLine}`;
if (scriptSetupRanges.defineProp.filter(p => p.isModel).length) {
yield `(await import('${options.vueCompilerOptions.lib}')).defineEmits<{${newLine}`;
for (const defineProp of scriptSetupRanges.defineProp) {
if (!defineProp.isModel) {
continue;
Expand All @@ -406,7 +406,9 @@ function* generateModelEmits(
}
yield `]${endOfLine}`;
}
yield `}>>`;
yield `}>()`;
} else {
yield `{}`;
}
yield endOfLine;
}

0 comments on commit 8df7c3c

Please sign in to comment.