Skip to content

Commit

Permalink
enhance(button): TS type optimization (#2825)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxKylin authored Dec 15, 2023
1 parent b50cbd3 commit be35844
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
9 changes: 4 additions & 5 deletions packages/web-vue/components/button/button-group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<script lang="ts">
import { defineComponent, PropType, provide, reactive, toRefs } from 'vue';
import { Status, Size } from '../_utils/constant';
import { Status, Size, BorderShape } from '../_utils/constant';
import { ButtonTypes } from './constants';
import { getPrefixCls } from '../_utils/global-config';
import { buttonGroupInjectionKey } from './context';
Expand All @@ -18,9 +19,7 @@ export default defineComponent({
* @en Children button types are divided into five types: secondary, primary, dashed, outline and text.
*/
type: {
type: String as PropType<
'primary' | 'secondary' | 'outline' | 'dashed' | 'text'
>,
type: String as PropType<ButtonTypes>,
},
/**
* @zh 按钮的状态
Expand All @@ -35,7 +34,7 @@ export default defineComponent({
* @en Button shape
*/
shape: {
type: String as PropType<'square' | 'round' | 'circle'>,
type: String as PropType<BorderShape>,
},
/**
* @zh 按钮的尺寸
Expand Down
9 changes: 4 additions & 5 deletions packages/web-vue/components/button/button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
*/
import type { PropType } from 'vue';
import { defineComponent, computed, toRefs, inject } from 'vue';
import { Status, Size } from '../_utils/constant';
import { Status, Size, BorderShape } from '../_utils/constant';
import { ButtonTypes } from './constants';
import { getPrefixCls } from '../_utils/global-config';
import { isString } from '../_utils/is';
import IconLoading from '../icon/icon-loading';
Expand All @@ -61,16 +62,14 @@ export default defineComponent({
* @defaultValue 'secondary'
*/
type: {
type: String as PropType<
'primary' | 'secondary' | 'outline' | 'dashed' | 'text'
>,
type: String as PropType<ButtonTypes>,
},
/**
* @zh 按钮的形状
* @en Button shape
*/
shape: {
type: String as PropType<'square' | 'round' | 'circle'>,
type: String as PropType<BorderShape>,
},
/**
* @zh 按钮的状态
Expand Down
7 changes: 4 additions & 3 deletions packages/web-vue/components/button/interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Size, Status } from '../_utils/constant';
import { Size, Status, BorderShape } from '../_utils/constant';
import { ButtonTypes } from './constants';

export interface ButtonProps {
type?: 'primary' | 'secondary' | 'outline' | 'dashed' | 'text';
shape?: 'square' | 'round' | 'circle';
type?: ButtonTypes;
shape?: BorderShape;
status?: Status;
size?: Size;
long?: boolean;
Expand Down

0 comments on commit be35844

Please sign in to comment.