Skip to content

Commit 07a6bcb

Browse files
authored
[improvement] default props in tsx (youzan#2789)
1 parent b9d7143 commit 07a6bcb

File tree

11 files changed

+21
-21
lines changed

11 files changed

+21
-21
lines changed

packages/button/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { CreateElement, RenderContext } from 'vue/types';
88
import { DefaultSlots } from '../utils/use/sfc';
99

1010
export type ButtonProps = RouteProps & {
11-
tag?: string;
12-
type?: string;
13-
size?: string;
11+
tag: string;
12+
type: string;
13+
size: string;
1414
text?: string;
1515
block?: boolean;
1616
plain?: boolean;

packages/card/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type CardProps = {
1313
thumb?: string;
1414
title?: string;
1515
price?: number | string;
16-
currency?: string;
16+
currency: string;
1717
centered?: boolean;
1818
lazyLoad?: boolean;
1919
thumbLink?: string;

packages/cell-group/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CreateElement, RenderContext } from 'vue/types';
66
import { DefaultSlots } from '../utils/use/sfc';
77

88
export type CellGroupProps = {
9-
border?: boolean
9+
border: boolean
1010
};
1111

1212
const [sfc, bem] = use('cell-group');

packages/cell/shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export type SharedCellProps = {
22
icon?: string;
3-
border?: boolean;
3+
border: boolean;
44
center?: boolean;
55
isLink?: boolean;
66
required?: boolean;

packages/contact-card/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export type ContactCardProps = {
1212
tel?: string;
1313
name?: string;
1414
type?: string;
15-
addText?: string;
16-
editable?: boolean;
15+
addText: string;
16+
editable: boolean;
1717
};
1818

1919
function ContactCard(

packages/icon/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type IconProps = {
1212
size?: string;
1313
color?: string;
1414
info?: string | number;
15-
classPrefix?: string;
15+
classPrefix: string;
1616
};
1717

1818
export type IconEvents = {

packages/loading/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { DefaultSlots } from '../utils/use/sfc';
77

88
export type LoadingProps = {
99
size?: string;
10-
type?: string;
11-
color?: string;
10+
type: string;
11+
color: string;
1212
};
1313

1414
const [sfc, bem] = use('loading');

packages/nav-bar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { ScopedSlot, DefaultSlots } from '../utils/use/sfc';
99
export type NavBarProps = {
1010
title?: string;
1111
fixed?: boolean;
12-
zIndex?: number;
13-
border?: boolean;
12+
zIndex: number;
13+
border: boolean;
1414
leftText?: string;
1515
rightText?: string;
1616
leftArrow?: boolean;

packages/switch-cell/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CreateElement, RenderContext } from 'vue/types';
99
import { DefaultSlots } from '../utils/use/sfc';
1010

1111
export type SwitchCellProps = SharedSwitchProps & {
12-
size?: string;
12+
size: string;
1313
title?: string;
1414
border?: boolean;
1515
};

packages/switch/shared.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
*/
44

55
export type SharedSwitchProps = {
6-
size?: string;
6+
size: string;
77
value?: any;
88
loading?: boolean;
99
disabled?: boolean;
10-
activeValue?: any;
11-
inactiveValue?: any;
10+
activeValue: any;
11+
inactiveValue: any;
1212
activeColor?: string;
1313
inactiveColor?: string;
1414
};

packages/utils/use/sfc.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ export type FunctionalComponent<
5353
};
5454

5555
export type TsxBaseProps = {
56-
class?: any;
57-
style?: any;
56+
class: any;
57+
style: any;
5858
// hack for jsx prop spread
59-
props?: any;
59+
props: any;
6060
};
6161
export type TsxComponent<Props, Events> = (
62-
props: Props & Events & TsxBaseProps
62+
props: Partial<Props & Events & TsxBaseProps>
6363
) => VNode;
6464

6565
const arrayProp = {

0 commit comments

Comments
 (0)