From 71d014d6910e9e43e135d7667fd8e6f33a60998d Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Sat, 19 Sep 2020 23:27:03 +0800 Subject: [PATCH] types(Loading): use tsx --- src/button/index.tsx | 4 ++-- src/loading/{index.js => index.tsx} | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) rename src/loading/{index.js => index.tsx} (88%) diff --git a/src/button/index.tsx b/src/button/index.tsx index a5b54bf5d..8034f452f 100644 --- a/src/button/index.tsx +++ b/src/button/index.tsx @@ -7,7 +7,7 @@ import { useRoute, routeProps } from '../composition/use-route'; // Components import Icon from '../icon'; -import Loading from '../loading'; +import Loading, { LoadingType } from '../loading'; const [createComponent, bem] = createNamespace('button'); @@ -35,7 +35,7 @@ export default createComponent({ disabled: Boolean, iconPrefix: String, loadingText: String, - loadingType: String, + loadingType: String as PropType, tag: { type: String as PropType, default: 'button', diff --git a/src/loading/index.js b/src/loading/index.tsx similarity index 88% rename from src/loading/index.js rename to src/loading/index.tsx index 1ec170bf9..9f813e64c 100644 --- a/src/loading/index.js +++ b/src/loading/index.tsx @@ -1,9 +1,9 @@ -import { computed } from 'vue'; +import { computed, PropType } from 'vue'; import { createNamespace, addUnit, getSizeStyle } from '../utils'; const [createComponent, bem] = createNamespace('loading'); -const SpinIcon = []; +const SpinIcon: JSX.Element[] = []; for (let i = 0; i < 12; i++) { SpinIcon.push(); } @@ -14,6 +14,8 @@ const CircularIcon = ( ); +export type LoadingType = 'circular' | 'spinner'; + export default createComponent({ props: { size: [Number, String], @@ -21,7 +23,7 @@ export default createComponent({ vertical: Boolean, textSize: [Number, String], type: { - type: String, + type: String as PropType, default: 'circular', }, },