Skip to content

Commit

Permalink
fix: global component type broken if components option not exist
Browse files Browse the repository at this point in the history
close #1061
  • Loading branch information
johnsoncodehk committed Mar 20, 2022
1 parent d3014ed commit 924f1e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -41,7 +41,7 @@ export function useSfcEntryForTemplateLs(
}
content += `declare var __VLS_ctx: __VLS_types.ComponentContext<typeof __VLS_component_ts>;\n`;
content += `declare var __VLS_ComponentsWrap: typeof __VLS_options & { components: { } };\n`;
content += `declare var __VLS_Components: NonNullable<typeof __VLS_component_ts.components> & typeof __VLS_ComponentsWrap.components & __VLS_types.GlobalComponents & __VLS_types.PickComponents<typeof __VLS_ctx> & __VLS_types.SelfComponent<typeof __VLS_name, typeof __VLS_component>;\n`;
content += `declare var __VLS_Components: NonNullable<typeof __VLS_component extends { components: infer C } ? C : {}> & typeof __VLS_ComponentsWrap.components & __VLS_types.GlobalComponents & __VLS_types.PickComponents<typeof __VLS_ctx> & __VLS_types.SelfComponent<typeof __VLS_name, typeof __VLS_component>;\n`;
content += `__VLS_ctx.${SearchTexts.Context};\n`;
content += `__VLS_Components.${SearchTexts.Components};\n`;
content += `({} as __VLS_types.OptionsSetupReturns<typeof __VLS_options_ts>).${SearchTexts.SetupReturns};\n`;
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-typescript/src/use/useSfcTemplateScript.ts
Expand Up @@ -87,7 +87,7 @@ export function useSfcTemplateScript(

/* Components */
codeGen.addText('/* Components */\n');
codeGen.addText('declare var __VLS_wrapComponentsRaw: NonNullable<typeof __VLS_component.components> & __VLS_types.GlobalComponents & typeof __VLS_vmUnwrap.components & __VLS_types.PickComponents<typeof __VLS_ctxRaw>;\n'); // has __VLS_options
codeGen.addText('declare var __VLS_wrapComponentsRaw: NonNullable<typeof __VLS_component extends { components: infer C } ? C : {}> & __VLS_types.GlobalComponents & typeof __VLS_vmUnwrap.components & __VLS_types.PickComponents<typeof __VLS_ctxRaw>;\n'); // has __VLS_options
codeGen.addText('declare var __VLS_ownComponent: __VLS_types.SelfComponent<typeof __VLS_name, typeof __VLS_component & { __VLS_raw: typeof __VLS_component, __VLS_options: typeof __VLS_options, __VLS_slots: typeof __VLS_slots }>;\n');
codeGen.addText('declare var __VLS_wrapComponents: typeof __VLS_wrapComponentsRaw & Omit<typeof __VLS_ownComponent, keyof typeof __VLS_wrapComponentsRaw>;\n');
codeGen.addText('declare var __VLS_rawComponents: __VLS_types.ConvertInvalidComponents<__VLS_types.ExtractRawComponents<typeof __VLS_wrapComponents>> & JSX.IntrinsicElements;\n'); // sort by priority
Expand Down

0 comments on commit 924f1e2

Please sign in to comment.