Skip to content

Commit

Permalink
patch the consumer side instead of the definer side
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Jul 13, 2023
1 parent 5522a7f commit 895cdd7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/vue-language-core/src/generators/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ declare function defineProp<T>(value?: T | (() => T), required?: boolean, rest?:
generateConstNameOption();

if (scriptSetupRanges?.slotsTypeArg && sfc.scriptSetup) {
codes.push(`var __VLS_slots!: __VLS_NormalizeSlots<`);
codes.push(`var __VLS_slots!: `);
addExtraReferenceVirtualCode('scriptSetup', scriptSetupRanges.slotsTypeArg.start, scriptSetupRanges.slotsTypeArg.end);
codes.push('>;\n');
codes.push(';\n');
};

codes.push(`function __VLS_template() {\n`);
Expand Down
3 changes: 2 additions & 1 deletion packages/vue-language-core/src/generators/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1596,14 +1596,15 @@ export function generate(

if (hasScriptSetupSlots) {
codes.push(
'__VLS_normalizeSlot(',
['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly],
'__VLS_slots[',
['', 'template', node.loc.start.offset, capabilitiesPresets.diagnosticOnly],
slotNameExpNode?.content ?? `('${getSlotName()}' as const)`,
['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly],
']',
['', 'template', node.loc.end.offset, capabilitiesPresets.diagnosticOnly],
'?.(',
')?.(',
['', 'template', startTagOffset, capabilitiesPresets.diagnosticOnly],
'{\n',
);
Expand Down
4 changes: 1 addition & 3 deletions packages/vue-language-core/src/utils/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,8 @@ declare function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K
T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
>;
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
type __VLS_NormalizeSlots<T> = {
[K in keyof T]: T[K] extends () => infer R ? (arg: any) => R : T[K]
}
declare function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
declare function __VLS_componentProps<T, K>(comp: T, fnReturn: K):
__VLS_PickNotAny<K, {}> extends { __ctx: { props: infer P } } ? NonNullable<P>
: T extends (props: infer P, ...args: any) => any ? NonNullable<P> :
Expand Down

0 comments on commit 895cdd7

Please sign in to comment.