UNPKG

@vue-macros/volar

Version:

Volar plugin for Vue Macros.

36 lines (23 loc) 1.57 kB
import * as typescript from 'typescript'; import type { FeatureName, OptionsResolved } from '@vue-macros/config'; import type { SFCScriptBlock } from '@vue-macros/common'; import type { Code, Sfc, VueLanguagePlugin } from '@vue/language-core'; declare const REGEX_DEFINE_COMPONENT: RegExp; declare function addProps(codes: Code[], decl: Code[], vueLibName: string): true | undefined; declare function addEmits(codes: Code[], decl: Code[], vueLibName: string): true | undefined; declare function addCode(codes: Code[], ...args: Code[]): void; type VueMacrosPlugin<K extends FeatureName> = (ctx: PluginContext, options?: OptionsResolved[K]) => ReturnType<VueLanguagePlugin>; type PluginContext = Parameters<VueLanguagePlugin>[0]; declare function getVolarOptions<K extends keyof OptionsResolved>(context: PluginContext, key: K): OptionsResolved[K]; interface VolarContext { ts: typeof typescript; ast?: typescript.SourceFile; sfc?: Sfc; source?: "script" | "scriptSetup"; } declare function getStart(node: typescript.Node | typescript.NodeArray<typescript.Node>, { ts, ast, sfc, source }: VolarContext): number; declare function getText(node: typescript.Node, context: VolarContext): string; declare function isJsxExpression(node?: typescript.Node): node is typescript.JsxExpression; declare function patchSFC(block: SFCScriptBlock | null, offset: number): void; export { REGEX_DEFINE_COMPONENT, addCode, addEmits, addProps, getStart, getText, getVolarOptions, isJsxExpression, patchSFC }; export type { PluginContext, VolarContext, VueMacrosPlugin };