chore: prettier all ts code

This commit is contained in:
陈嘉涵
2020-01-19 15:27:28 +08:00
parent 04c49b645a
commit 207e80f396
19 changed files with 124 additions and 68 deletions
+12 -4
View File
@@ -4,7 +4,12 @@
import '../../locale';
import { camelize } from '../format/string';
import { SlotsMixin } from '../../mixins/slots';
import Vue, { VNode, VueConstructor, ComponentOptions, RenderContext } from 'vue';
import Vue, {
VNode,
VueConstructor,
ComponentOptions,
RenderContext,
} from 'vue';
import { DefaultProps, FunctionComponent } from '../types';
export interface VantComponentOptions extends ComponentOptions<Vue> {
@@ -47,17 +52,20 @@ export function unifySlots(context: RenderContext) {
}
// should be removed after Vue 3
function transformFunctionComponent(pure: FunctionComponent): VantComponentOptions {
function transformFunctionComponent(
pure: FunctionComponent
): VantComponentOptions {
return {
functional: true,
props: pure.props,
model: pure.model,
render: (h, context): any => pure(h, context.props, unifySlots(context), context),
render: (h, context): any =>
pure(h, context.props, unifySlots(context), context),
};
}
export function createComponent(name: string) {
return function<Props = DefaultProps, Events = {}, Slots = {}> (
return function<Props = DefaultProps, Events = {}, Slots = {}>(
sfc: VantComponentOptions | FunctionComponent
): TsxComponent<Props, Events, Slots> {
if (typeof sfc === 'function') {
+3 -1
View File
@@ -6,7 +6,9 @@ export function createI18N(name: string) {
const prefix = camelize(name) + '.';
return function(path: string, ...args: any[]): string {
const message = get(locale.messages(), prefix + path) || get(locale.messages(), path);
const messages = locale.messages();
const message = get(messages, prefix + path) || get(messages, path);
return typeof message === 'function' ? message(...args) : message;
};
}