diff --git a/eslint.config.mjs b/eslint.config.mjs index f84818c..f1ca17d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -7,9 +7,18 @@ export default antfu({ semi: true, }, vue: true, + languageOptions: { + globals: { + uni: "readonly", + getCurrentPages: "readonly", + getApp: "readonly", + }, + }, rules: { "max-len": ["error", { code: 100 }], "style/no-tabs": ["off"], + "vue/eqeqeq": ["off"], + "vue/require-prop-type-constructor": ["off"], }, ignores: [ "uni_modules/**/*", @@ -17,6 +26,6 @@ export default antfu({ "wxcomponents/**/*", "unpackage/**/*", "uniCloud-aliyun/**/*", - "utils/css.js" + "utils/css.js", ], }); diff --git a/jsconfig.json b/jsconfig.json index 965fd10..10a0773 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,4 +1,7 @@ { + "vueCompilerOptions": { + "globalTypesPath": "types/global.d.ts" + }, "compilerOptions": { "baseUrl": ".", "paths": { diff --git a/types/global.d.ts b/types/global.d.ts new file mode 100644 index 0000000..f0fe46c --- /dev/null +++ b/types/global.d.ts @@ -0,0 +1,137 @@ +// @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 ? { [K in N0]: LocalComponents[N1] } : + N2 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N2] } : + N3 extends keyof LocalComponents ? { [K in N0]: LocalComponents[N3] } : + Self extends object ? { [K in N0]: Self } : + N1 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N1] } : + N2 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N2] } : + N3 extends keyof __VLS_GlobalComponents ? { [K in N0]: __VLS_GlobalComponents[N3] } : + {}; + 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< + Props, + Emits, + onEvent extends keyof Props, + Event extends keyof Emits, + CamelizedEvent extends keyof Emits, + > = __VLS_IsFunction extends true + ? Props + : __VLS_IsFunction extends true + ? { [K in onEvent]?: Emits[Event] } + : __VLS_IsFunction extends true + ? { [K in onEvent]?: Emits[CamelizedEvent] } + : Props; + // 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_EmitsToProps = __VLS_PrettifyGlobal<{ + [K in string & keyof T as `on${Capitalize}`]?: + (...args: T[K] extends (...args: infer P) => any ? P : T[K] extends null ? any[] : never) => any; + }>; + 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 keyof T & string as `v${Capitalize}`]: T[K]; + }; + type __VLS_PrettifyGlobal = { [K in keyof T as K]: T[K]; } & {}; + type __VLS_WithDefaultsGlobal = { + [K in keyof P as K extends keyof D ? K : never]-?: P[K]; + } & { + [K in keyof P as K extends keyof D ? never : K]: P[K]; + }; + type __VLS_UseTemplateRef = Readonly>; + type __VLS_ProxyRefs = import('vue').ShallowUnwrapRef; + + 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_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; +}