mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
[build] add typescript compiler (#2697)
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
const ELEMENT = '__';
|
||||
const MODS = '--';
|
||||
|
||||
const join = (name, el, symbol) => (el ? name + symbol + el : name);
|
||||
const join = (name: string, el: string, symbol: string) => (el ? name + symbol + el : name);
|
||||
|
||||
const prefix = (name, mods) => {
|
||||
const prefix = (name: string, mods: any): any => {
|
||||
if (typeof mods === 'string') {
|
||||
return join(name, mods, MODS);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ const prefix = (name, mods) => {
|
||||
return mods.map(item => prefix(name, item));
|
||||
}
|
||||
|
||||
const ret = {};
|
||||
const ret: { [key: string]: any } = {};
|
||||
if (mods) {
|
||||
Object.keys(mods).forEach(key => {
|
||||
ret[name + MODS + key] = mods[key];
|
||||
@@ -31,7 +31,7 @@ const prefix = (name, mods) => {
|
||||
return ret;
|
||||
};
|
||||
|
||||
export default name => (el, mods) => {
|
||||
export default (name: string) => (el: any, mods?: any) => {
|
||||
if (el && typeof el !== 'string') {
|
||||
mods = el;
|
||||
el = '';
|
@@ -1,9 +1,9 @@
|
||||
import { get, camelize } from '..';
|
||||
import { lang, messages } from '../../locale';
|
||||
|
||||
export default name => {
|
||||
export default (name: string) => {
|
||||
const prefix = camelize(name) + '.';
|
||||
return (path, ...args) => {
|
||||
return (path: string, ...args: any[]): string => {
|
||||
const message = get(messages[lang], prefix + path) || get(messages[lang], path);
|
||||
return typeof message === 'function' ? message(...args) : message;
|
||||
};
|
@@ -2,7 +2,13 @@ import useBem from './bem';
|
||||
import useSfc from './sfc';
|
||||
import useI18n from './i18n';
|
||||
|
||||
export function use(name) {
|
||||
type UseReturn = [
|
||||
ReturnType<typeof useSfc>,
|
||||
ReturnType<typeof useBem>,
|
||||
ReturnType<typeof useI18n>
|
||||
];
|
||||
|
||||
export function use(name: string): UseReturn {
|
||||
name = 'van-' + name;
|
||||
return [useSfc(name), useBem(name), useI18n(name)];
|
||||
}
|
Reference in New Issue
Block a user