Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3dcf60d

Browse files
authored
feat(volar/jsx-directive): support VaporInstance (#993)
* feat(volar/jsx-directive): support VaporInstance* chore: update
1 parent872eb54 commit3dcf60d

File tree

1 file changed

+52
-14
lines changed

1 file changed

+52
-14
lines changed

‎packages/volar/src/jsx-directive/context.ts‎

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,58 @@ export function resolveCtxMap(
1818
):Map<import('typescript').Node,string>{
1919
if(ctxNodeMap.size){
2020
options.codes.push(`
21-
// @ts-ignore
2221
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false; type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
23-
type __VLS_Element = globalThis.JSX.Element;
24-
declare function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
25-
T extends new (...args: any) => any
26-
? (props: (K extends { $props: infer Props } ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & { __ctx?: {
27-
attrs?: any,
28-
slots?: K extends { $scopedSlots: infer Slots } ? Slots : K extends { $slots: infer Slots } ? Slots : any,
29-
emit?: K extends { $emit: infer Emit } ? Emit : any
30-
} & { props?: (K extends { $props: infer Props } ? Props : any) & Record<string, unknown>; expose?(exposed: K): void; } }
31-
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
32-
: T extends (...args: any) => any ? T
33-
: (_: {} & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {} & Record<string, unknown> } };
22+
declare function __VLS_asFunctionalComponent<
23+
T,
24+
K = T extends new (...args: any) => any ? InstanceType<T> : unknown,
25+
>(
26+
t: T,
27+
instance?: K,
28+
): T extends new (...args: any) => any
29+
? (
30+
props: (K extends { $props: infer Props }
31+
? Props
32+
: K extends { props: infer Props }
33+
? Props
34+
: any),
35+
ctx?: any,
36+
) => JSX.Element & {
37+
__ctx: {
38+
attrs?: Record<string, any>,
39+
props: (K extends { $props: infer Props }
40+
? Props
41+
: K extends { props: infer Props }
42+
? Props
43+
: any),
44+
slots?: K extends { $slots: infer Slots }
45+
? Slots
46+
: K extends { slots: infer Slots }
47+
? Slots
48+
: any
49+
emit?: K extends { $emit: infer Emit }
50+
? Emit
51+
: K extends { emit: infer Emit }
52+
? Emit
53+
: any
54+
expose?: (exposed: K extends { exposeProxy: infer Exposed }
55+
? keyof Exposed extends never
56+
? K
57+
: Exposed
58+
: K) => void
59+
}
60+
}
61+
: T extends () => any
62+
? (props: {}, ctx?: any) => ReturnType<T>
63+
: T extends (...args: any) => any
64+
? T
65+
: (_: {}, ctx?: any) => {
66+
__ctx: {
67+
attrs?: any
68+
expose?: any
69+
slots?: any
70+
emit?: any
71+
}
72+
};
3473
const __VLS_nativeElements = {
3574
...{} as SVGElementTagNameMap,
3675
...{} as HTMLElementTagNameMap,
@@ -41,8 +80,7 @@ declare function __VLS_getFunctionalComponentCtx<T, K, const S>(
4180
s: S,
4281
): S extends keyof typeof __VLS_nativeElements
4382
? { expose: (exposed: (typeof __VLS_nativeElements)[S]) => any }
44-
: T extends { setup: (props: infer P, ctx: infer Ctx) => any } ? { props: P } & Ctx :
45-
'__ctx' extends keyof __VLS_PickNotAny<K, {}>
83+
: '__ctx' extends keyof __VLS_PickNotAny<K, {}>
4684
? K extends { __ctx?: infer Ctx } ? Ctx : never
4785
: T extends (props: infer P, ctx: infer Ctx) => any ? { props: P } & Ctx
4886
: {};\n`)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp