[improvement] Cell: tsx (#2771)

This commit is contained in:
neverland
2019-02-17 20:29:49 +08:00
committed by GitHub
parent 890bd72268
commit 34e30aac5e
4 changed files with 52 additions and 17 deletions

View File

@@ -7,8 +7,8 @@
* b(['disabled', 'primary']) // 'button button--disabled button--primary'
*/
type Mod = string | { [key: string]: any };
type Mods = Mod | Mod[];
export type Mod = string | { [key: string]: any };
export type Mods = Mod | Mod[];
const ELEMENT = '__';
const MODS = '--';

View File

@@ -47,7 +47,11 @@ export type FunctionalComponent<
inject?: InjectOptions;
};
export type VantTsxComponent<T> = (props: T) => VNode;
export type TsxBaseProps = {
class?: any;
style?: any;
}
export type TsxComponent<T> = (props: T & TsxBaseProps) => VNode;
const arrayProp = {
type: Array,
@@ -104,7 +108,7 @@ function transformFunctionalComponent(
export default (name: string) => <T = DefaultProps>(
sfc: VantComponentOptions | FunctionalComponent
): VantTsxComponent<T> => {
): TsxComponent<T> => {
if (typeof sfc === 'function') {
sfc = transformFunctionalComponent(sfc);
}
@@ -121,5 +125,5 @@ export default (name: string) => <T = DefaultProps>(
sfc.name = name;
sfc.install = install;
return sfc as VantTsxComponent<T>;
return sfc as TsxComponent<T>;
};