|
| 1 | +import { computed, defineComponent, defineVaporComponent, ref } from 'vue' |
| 2 | +import { useRef } from 'vue-jsx-vapor' |
| 3 | + |
| 4 | +const Comp = (() => { |
| 5 | + const __setup = ( |
| 6 | + __props: typeof __ctx.props & {}, |
| 7 | + __context?: typeof __ctx.context, |
| 8 | + __ctx = {} as Awaited<ReturnType<typeof __fn>>, |
| 9 | + __fn = ({ count = 0 }) => { |
| 10 | + const __exposed = defineExpose({ |
| 11 | + double: computed(() => count * 2), |
| 12 | + }) |
| 13 | + const __render = ( |
| 14 | + <span> x 2 = </span> |
| 15 | + ) as unknown as __InferJsxElement<'span'> |
| 16 | + return {} as { |
| 17 | + props: { count?: typeof count } |
| 18 | + context: {} & { |
| 19 | + slots: {} |
| 20 | + expose: (exposed: {}) => void |
| 21 | + attrs: Record<string, any> |
| 22 | + } |
| 23 | + render: typeof __render |
| 24 | + } |
| 25 | + }, |
| 26 | + ) => __ctx.render |
| 27 | + type __Setup = typeof __setup |
| 28 | + type __Props = Parameters<__Setup>[0] |
| 29 | + type __Slots = Parameters<__Setup>[1] extends |
| 30 | + | { slots?: infer Slots } |
| 31 | + | undefined |
| 32 | + ? Slots |
| 33 | + : {} |
| 34 | + type __Exposed = Parameters<__Setup>[1] extends |
| 35 | + | { expose?: (exposed: infer Exposed) => any } |
| 36 | + | undefined |
| 37 | + ? Exposed |
| 38 | + : {} |
| 39 | + const __component = // @ts-ignore |
| 40 | + (defineVaporComponent, await import('vue-jsx-vapor')).defineVaporComponent({ |
| 41 | + ...({} as { |
| 42 | + setup: (props: __Props) => __Exposed |
| 43 | + render: () => ReturnType<__Setup> |
| 44 | + slots: __Slots |
| 45 | + }), |
| 46 | + }) |
| 47 | + return {} as Omit<typeof __component, 'constructor'> & { |
| 48 | + new (props?: __Props): InstanceType<typeof __component> & { |
| 49 | + /** @deprecated This is only a type when used in Vapor Instances. */ |
| 50 | + $props: __Props |
| 51 | + } |
| 52 | + } |
| 53 | +})() |
| 54 | +const comp = (<Comp />) as unknown as __InferJsxElement<typeof Comp> |
| 55 | +comp.exposeProxy |
| 56 | + |
| 57 | +export default (() => { |
| 58 | + const __setup = ( |
| 59 | + __props: typeof __ctx.props & {}, |
| 60 | + __context?: typeof __ctx.context, |
| 61 | + __ctx = {} as Awaited<ReturnType<typeof __fn>>, |
| 62 | + __fn = () => { |
| 63 | + const count = ref(1) |
| 64 | + const compRef = useRef< |
| 65 | + Parameters<NonNullable<(typeof __VLS_ctx_compRef)['expose']>>[0] | null |
| 66 | + >() |
| 67 | + const zmj = {} as Required<(typeof __VLS_ctx_compRef)['expose']> |
| 68 | + const __render: () => JSX.Element = () => ( |
| 69 | + <> |
| 70 | + <input value={count.value} /> |
| 71 | + <Comp ref={compRef} count={count.value}></Comp> |
| 72 | + {compRef.value?.double} |
| 73 | + </> |
| 74 | + ) |
| 75 | + return {} as { |
| 76 | + props: {} |
| 77 | + context: {} & { |
| 78 | + slots: {} |
| 79 | + expose: (exposed: {}) => void |
| 80 | + attrs: Record<string, any> |
| 81 | + } |
| 82 | + render: typeof __render |
| 83 | + } |
| 84 | + |
| 85 | + const __VLS_ctx_compRef = __VLS_getFunctionalComponentCtx( |
| 86 | + Comp, |
| 87 | + __VLS_asFunctionalComponent(Comp)({ count: count.value }), |
| 88 | + 'Comp', |
| 89 | + ) |
| 90 | + }, |
| 91 | + ) => __ctx.render |
| 92 | + type __Setup = typeof __setup |
| 93 | + type __Props = Parameters<__Setup>[0] |
| 94 | + type __Slots = Parameters<__Setup>[1] extends |
| 95 | + | { slots?: infer Slots } |
| 96 | + | undefined |
| 97 | + ? Slots |
| 98 | + : {} |
| 99 | + type __Exposed = Parameters<__Setup>[1] extends |
| 100 | + | { expose?: (exposed: infer Exposed) => any } |
| 101 | + | undefined |
| 102 | + ? Exposed |
| 103 | + : {} |
| 104 | + const __component = defineComponent({ |
| 105 | + ...({} as { |
| 106 | + setup: (props: __Props) => __Exposed |
| 107 | + render: () => ReturnType<__Setup> |
| 108 | + slots: import('vue').SlotsType<__Slots> |
| 109 | + }), |
| 110 | + }) |
| 111 | + return {} as Omit<typeof __component, 'constructor'> & { |
| 112 | + new (props?: __Props): InstanceType<typeof __component> & {} |
| 113 | + } |
| 114 | +})() |
| 115 | + |
| 116 | +type __VLS_IsAny<T> = 0 extends 1 & T ? true : false |
| 117 | +type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A |
| 118 | +declare function __VLS_asFunctionalComponent< |
| 119 | + T, |
| 120 | + K = T extends new (...args: any) => any ? InstanceType<T> : unknown, |
| 121 | +>( |
| 122 | + t: T, |
| 123 | + instance?: K, |
| 124 | +): T extends new (...args: any) => any |
| 125 | + ? ( |
| 126 | + props: K extends { $props: infer Props } |
| 127 | + ? Props |
| 128 | + : K extends { props: infer Props } |
| 129 | + ? Props |
| 130 | + : any, |
| 131 | + ctx?: any, |
| 132 | + ) => JSX.Element & { |
| 133 | + __ctx: { |
| 134 | + attrs?: Record<string, any> |
| 135 | + props: K extends { $props: infer Props } |
| 136 | + ? Props |
| 137 | + : K extends { props: infer Props } |
| 138 | + ? Props |
| 139 | + : any |
| 140 | + slots?: K extends { $slots: infer Slots } |
| 141 | + ? Slots |
| 142 | + : K extends { slots: infer Slots } |
| 143 | + ? Slots |
| 144 | + : any |
| 145 | + emit?: K extends { $emit: infer Emit } |
| 146 | + ? Emit |
| 147 | + : K extends { emit: infer Emit } |
| 148 | + ? Emit |
| 149 | + : any |
| 150 | + expose?: ( |
| 151 | + exposed: K extends { exposeProxy: infer Exposed } |
| 152 | + ? keyof Exposed extends never |
| 153 | + ? K |
| 154 | + : Exposed |
| 155 | + : K, |
| 156 | + ) => void |
| 157 | + } |
| 158 | + } |
| 159 | + : T extends () => any |
| 160 | + ? (props: {}, ctx?: any) => ReturnType<T> |
| 161 | + : T extends (...args: any) => any |
| 162 | + ? T |
| 163 | + : ( |
| 164 | + _: {}, |
| 165 | + ctx?: any, |
| 166 | + ) => { |
| 167 | + __ctx: { |
| 168 | + attrs?: any |
| 169 | + expose?: any |
| 170 | + slots?: any |
| 171 | + emit?: any |
| 172 | + } |
| 173 | + } |
| 174 | +const __VLS_nativeElements = { |
| 175 | + ...({} as SVGElementTagNameMap), |
| 176 | + ...({} as HTMLElementTagNameMap), |
| 177 | +} |
| 178 | +declare function __VLS_getFunctionalComponentCtx<T, K, const S>( |
| 179 | + comp: T, |
| 180 | + compInstance: K, |
| 181 | + s: S, |
| 182 | +): S extends keyof typeof __VLS_nativeElements |
| 183 | + ? { expose: (exposed: (typeof __VLS_nativeElements)[S]) => any } |
| 184 | + : '__ctx' extends keyof __VLS_PickNotAny<K, {}> |
| 185 | + ? K extends { __ctx?: infer Ctx } |
| 186 | + ? Ctx |
| 187 | + : never |
| 188 | + : T extends (props: infer P, ctx: infer Ctx) => any |
| 189 | + ? { props: P } & Ctx |
| 190 | + : {} |
| 191 | + |
| 192 | +type __VLS_NormalizeProps<T> = T extends object |
| 193 | + ? { |
| 194 | + [K in keyof T as {} extends Record<K, 1> |
| 195 | + ? never |
| 196 | + : K extends keyof import('vue').VNodeProps | 'class' | 'style' |
| 197 | + ? never |
| 198 | + : K]: T[K] |
| 199 | + } |
| 200 | + : never |
| 201 | +type __VLS_CamelCase<S extends string> = |
| 202 | + S extends `${infer F}-${infer RF}${infer R}` |
| 203 | + ? `${F}${Uppercase<RF>}${__VLS_CamelCase<R>}` |
| 204 | + : S |
| 205 | +type __VLS_PropsToEmits<T> = T extends object |
| 206 | + ? { |
| 207 | + [K in keyof T as K extends `onUpdate:${infer R}` |
| 208 | + ? R extends 'modelValue' |
| 209 | + ? never |
| 210 | + : __VLS_CamelCase<R> |
| 211 | + : never]: T[K] |
| 212 | + } |
| 213 | + : never |
| 214 | +type __VLS_GetModels<P, E = __VLS_PropsToEmits<P>> = P extends object |
| 215 | + ? { |
| 216 | + [K in keyof P as K extends keyof E ? K : never]: K extends keyof P |
| 217 | + ? P[K] |
| 218 | + : never |
| 219 | + } |
| 220 | + : {} |
| 221 | + |
| 222 | +declare const { defineModel }: typeof import('vue') |
| 223 | +declare function defineSlots<T extends Record<string, any>>(): Partial<T> |
| 224 | +declare function defineSlots<T extends Record<string, any>>(slots: T): T |
| 225 | +declare function defineExpose< |
| 226 | + Exposed extends Record<string, any> = Record<string, any>, |
| 227 | +>(exposed?: Exposed): Exposed |
| 228 | +declare const defineStyle: { |
| 229 | + <T>(...args: __StyleArgs): T |
| 230 | + scss: <T>(...args: __StyleArgs) => T |
| 231 | + sass: <T>(...args: __StyleArgs) => T |
| 232 | + stylus: <T>(...args: __StyleArgs) => T |
| 233 | + less: <T>(...args: __StyleArgs) => T |
| 234 | + postcss: <T>(...args: __StyleArgs) => T |
| 235 | +} |
| 236 | +type __StyleArgs = [style: string, options?: { scoped?: boolean }] |
| 237 | + |
| 238 | +type __InferJsxElement<T> = T extends keyof HTMLElementTagNameMap |
| 239 | + ? HTMLElementTagNameMap[T] |
| 240 | + : T extends keyof SVGElementTagNameMap |
| 241 | + ? SVGElementTagNameMap[T] |
| 242 | + : T extends (...args: any[]) => any |
| 243 | + ? ReturnType<T> |
| 244 | + : T extends { new (...args: any[]): infer Instance } |
| 245 | + ? Instance extends { $: any } |
| 246 | + ? import('vue').VNode |
| 247 | + : Instance |
| 248 | + : JSX.Element |
0 commit comments