From 2a38a9d394650e9ff13ff10a56d8644c07e8ba1d Mon Sep 17 00:00:00 2001 From: yangzhe Date: Thu, 24 Jul 2025 15:34:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20TypeScript=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=20Vue=20=E7=BB=84=E4=BB=B6=E7=B1=BB=E5=9E=8B=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tsconfig.json | 5 ++ types/global.d.ts | 124 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 tsconfig.json create mode 100644 types/global.d.ts diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..c1e495e --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,5 @@ +{ + "vueCompilerOptions": { + "globalTypesPath": "./types/global.d.ts" + } +} \ No newline at end of file diff --git a/types/global.d.ts b/types/global.d.ts new file mode 100644 index 0000000..2f01bb4 --- /dev/null +++ b/types/global.d.ts @@ -0,0 +1,124 @@ +// @ts-nocheck +export {}; + +; declare global { + const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any }; + const __VLS_unref: typeof import('vue').unref; + const __VLS_placeholder: any; + + type __VLS_NativeElements = __VLS_SpreadMerge; + type __VLS_IntrinsicElements = import('vue/jsx-runtime').JSX.IntrinsicElements; + type __VLS_Element = import('vue/jsx-runtime').JSX.Element; + type __VLS_GlobalComponents = import('vue').GlobalComponents; + type __VLS_GlobalDirectives = import('vue').GlobalDirectives; + type __VLS_IsAny = 0 extends 1 & T ? true : false; + type __VLS_PickNotAny = __VLS_IsAny extends true ? B : A; + type __VLS_SpreadMerge = Omit & B; + type __VLS_WithComponent = + N1 extends keyof LocalComponents ? N1 extends N0 ? Pick : { [K in N0]: LocalComponents[N1] } : + N2 extends keyof LocalComponents ? N2 extends N0 ? Pick : { [K in N0]: LocalComponents[N2] } : + N3 extends keyof LocalComponents ? N3 extends N0 ? Pick : { [K in N0]: LocalComponents[N3] } : + Self extends object ? { [K in N0]: Self } : + N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } : + N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } : + N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } : + { [K in N0]: unknown }; + type __VLS_FunctionalComponentCtx = __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny + ? K extends { __ctx?: infer Ctx } ? NonNullable : never : any + , T extends (props: any, ctx: infer Ctx) => any ? Ctx : any + >; + type __VLS_FunctionalComponentProps = '__ctx' extends keyof __VLS_PickNotAny + ? K extends { __ctx?: { props?: infer P } } ? NonNullable

: never + : T extends (props: infer P, ...args: any) => any ? P + : {}; + type __VLS_FunctionalComponent = (props: (T extends { $props: infer Props } ? Props : {}) & Record, ctx?: any) => __VLS_Element & { + __ctx?: { + attrs?: any, + slots?: T extends { $slots: infer Slots } ? Slots : Record, + emit?: T extends { $emit: infer Emit } ? Emit : {}, + props?: (T extends { $props: infer Props } ? Props : {}) & Record, + expose?: (exposed: T) => void, + } + }; + type __VLS_IsFunction = K extends keyof T + ? __VLS_IsAny extends false + ? unknown extends T[K] + ? false + : true + : false + : false; + type __VLS_NormalizeComponentEvent = ( + __VLS_IsFunction extends true + ? Props + : __VLS_IsFunction extends true + ? { [K in onEvent]?: Emits[Event] } + : __VLS_IsFunction extends true + ? { [K in onEvent]?: Emits[CamelizedEvent] } + : Props + ) & Record; + // fix https://github.com/vuejs/language-tools/issues/926 + type __VLS_UnionToIntersection = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never; + type __VLS_OverloadUnionInner = U & T extends (...args: infer A) => infer R + ? U extends T + ? never + : __VLS_OverloadUnionInner & U & ((...args: A) => R)> | ((...args: A) => R) + : never; + type __VLS_OverloadUnion = Exclude< + __VLS_OverloadUnionInner<(() => never) & T>, + T extends () => never ? never : () => never + >; + type __VLS_ConstructorOverloads = __VLS_OverloadUnion extends infer F + ? F extends (event: infer E, ...args: infer A) => any + ? { [K in E & string]: (...args: A) => void; } + : never + : never; + type __VLS_NormalizeEmits = __VLS_PrettifyGlobal< + __VLS_UnionToIntersection< + __VLS_ConstructorOverloads & { + [K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never + } + > + >; + type __VLS_ResolveEmits< + Comp, + Emits, + TypeEmits = Comp extends { __typeEmits?: infer T } ? unknown extends T ? {} : import('vue').ShortEmitsToObject : {}, + NormalizedEmits = __VLS_NormalizeEmits extends infer E ? string extends keyof E ? {} : E : never, + > = __VLS_SpreadMerge; + type __VLS_ResolveDirectives = { + [K in Exclude & string as `v${Capitalize}`]: T[K]; + }; + type __VLS_PrettifyGlobal = { [K in keyof T as K]: T[K]; } & {}; + type __VLS_UseTemplateRef = Readonly>; + + function __VLS_getVForSourceType>(source: T): [ + item: T extends number ? number + : T extends string ? string + : T extends any[] ? T[number] + : T extends Iterable ? T1 + : any, + index: number, + ][]; + function __VLS_getVForSourceType(source: T): [ + item: T[keyof T], + key: keyof T, + index: number, + ][]; + function __VLS_getSlotParameters(slot: S, decl?: D): + D extends (...args: infer P) => any ? P : any[]; + function __VLS_asFunctionalDirective(dir: T): T extends import('vue').ObjectDirective + ? NonNullable + : T extends (...args: any) => any + ? T + : (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void; + function __VLS_makeOptional(t: T): { [K in keyof T]?: T[K] }; + function __VLS_asFunctionalComponent any ? InstanceType : unknown>(t: T, instance?: K): + T extends new (...args: any) => any ? __VLS_FunctionalComponent + : T extends () => any ? (props: {}, ctx?: any) => ReturnType + : T extends (...args: any) => any ? T + : __VLS_FunctionalComponent<{}>; + function __VLS_functionalComponentArgsRest any>(t: T): 2 extends Parameters['length'] ? [any] : []; + function __VLS_asFunctionalElement(tag: T, endTag?: T): (attrs: T & Record) => void; + function __VLS_asFunctionalSlot(slot: S): S extends () => infer R ? (props: {}) => R : NonNullable; + function __VLS_tryAsConstant(t: T): T; +}