mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-22 22:49:15 +08:00
27 lines
671 B
TypeScript
27 lines
671 B
TypeScript
import { App } from 'vue';
|
|
import { camelize } from './format/string';
|
|
|
|
// https://github.com/youzan/vant/issues/8302
|
|
type EventShim = {
|
|
new (...args: any[]): {
|
|
$props: {
|
|
onClick?: (...args: any[]) => void;
|
|
};
|
|
};
|
|
};
|
|
|
|
export type WithInstall<T> = T & {
|
|
install(app: App): void;
|
|
} & EventShim;
|
|
|
|
// using any here because tsc will generate some weird results when using generics
|
|
export function withInstall<T>(options: any): WithInstall<T> {
|
|
(options as Record<string, unknown>).install = (app: App) => {
|
|
const { name } = options as any;
|
|
app.component(name, options);
|
|
app.component(camelize(`-${name}`), options);
|
|
};
|
|
|
|
return options;
|
|
}
|