perf: update ts types

pull/2992/head
tanjinzhou 2020-10-13 15:39:08 +08:00
parent b817873c15
commit 1503364d6b
3 changed files with 13 additions and 11 deletions

View File

@ -19,6 +19,7 @@ const BackTop = defineComponent({
name: 'ABackTop', name: 'ABackTop',
inheritAttrs: false, inheritAttrs: false,
mixins: [BaseMixin], mixins: [BaseMixin],
emits: ['click'],
props: { props: {
...props, ...props,
visibilityHeight: PropTypes.number.def(400), visibilityHeight: PropTypes.number.def(400),
@ -57,7 +58,7 @@ const BackTop = defineComponent({
return targetNode.scrollTop; return targetNode.scrollTop;
}, },
scrollToTop(e) { scrollToTop(e: Event) {
const { target = getDefaultTarget } = this; const { target = getDefaultTarget } = this;
scrollTo(0, { scrollTo(0, {
getContainer: target, getContainer: target,

View File

@ -79,7 +79,7 @@ export default defineComponent({
} }
: { ...numberStyle }; : { ...numberStyle };
}, },
getBadgeClassName(prefixCls, children) { getBadgeClassName(prefixCls: string, children: any[]) {
const hasStatus = this.hasStatus(); const hasStatus = this.hasStatus();
return classNames(prefixCls, { return classNames(prefixCls, {
[`${prefixCls}-status`]: hasStatus, [`${prefixCls}-status`]: hasStatus,
@ -111,7 +111,7 @@ export default defineComponent({
return (isEmpty || (isZero && !showZero)) && !isDot; return (isEmpty || (isZero && !showZero)) && !isDot;
}, },
renderStatusText(prefixCls) { renderStatusText(prefixCls: string) {
const text = getComponent(this, 'text'); const text = getComponent(this, 'text');
const hidden = this.isHidden(); const hidden = this.isHidden();
return hidden || !text ? null : <span class={`${prefixCls}-status-text`}>{text}</span>; return hidden || !text ? null : <span class={`${prefixCls}-status-text`}>{text}</span>;
@ -132,7 +132,7 @@ export default defineComponent({
); );
}, },
renderBadgeNumber(prefixCls, scrollNumberPrefixCls) { renderBadgeNumber(prefixCls: string, scrollNumberPrefixCls: string) {
const { status, color } = this.$props; const { status, color } = this.$props;
const count = this.badgeCount; const count = this.badgeCount;
const displayCount = this.getDispayCount(); const displayCount = this.getDispayCount();

View File

@ -6,7 +6,7 @@ import { cloneElement } from '../_util/vnode';
import { defaultConfigProvider } from '../config-provider'; import { defaultConfigProvider } from '../config-provider';
import { CSSProperties, defineComponent, inject } from 'vue'; import { CSSProperties, defineComponent, inject } from 'vue';
function getNumberArray(num) { function getNumberArray(num: string | number | undefined | null) {
return num return num
? num ? num
.toString() .toString()
@ -33,6 +33,7 @@ export default defineComponent({
mixins: [BaseMixin], mixins: [BaseMixin],
inheritAttrs: false, inheritAttrs: false,
props: ScrollNumberProps, props: ScrollNumberProps,
emits: ['animated'],
setup() { setup() {
return { return {
configProvider: inject('configProvider', defaultConfigProvider), configProvider: inject('configProvider', defaultConfigProvider),
@ -81,12 +82,12 @@ export default defineComponent({
this.timeout = undefined; this.timeout = undefined;
} }
}, },
getPositionByNum(num, i) { getPositionByNum(num: number, i: number) {
const { sCount } = this; const { sCount } = this;
const currentCount = Math.abs(Number(sCount)); const currentCount = Math.abs(Number(sCount));
const lastCount = Math.abs(Number(this.lastCount)); const lastCount = Math.abs(Number(this.lastCount));
const currentDigit = Math.abs(getNumberArray(sCount)[i]); const currentDigit = Math.abs(getNumberArray(sCount)[i] as number);
const lastDigit = Math.abs(getNumberArray(this.lastCount)[i]); const lastDigit = Math.abs(getNumberArray(this.lastCount)[i] as number);
if (this.animateStarted) { if (this.animateStarted) {
return 10 + num; return 10 + num;
@ -107,7 +108,7 @@ export default defineComponent({
this.$emit('animated'); this.$emit('animated');
}, },
renderNumberList(position, className) { renderNumberList(position: number, className: string) {
const childrenToReturn = []; const childrenToReturn = [];
for (let i = 0; i < 30; i++) { for (let i = 0; i < 30; i++) {
childrenToReturn.push( childrenToReturn.push(
@ -124,7 +125,7 @@ export default defineComponent({
return childrenToReturn; return childrenToReturn;
}, },
renderCurrentNumber(prefixCls, num, i) { renderCurrentNumber(prefixCls: string, num: number | string, i: number) {
if (typeof num === 'number') { if (typeof num === 'number') {
const position = this.getPositionByNum(num, i); const position = this.getPositionByNum(num, i);
const removeTransition = const removeTransition =
@ -148,7 +149,7 @@ export default defineComponent({
); );
}, },
renderNumberElement(prefixCls) { renderNumberElement(prefixCls: string) {
const { sCount } = this; const { sCount } = this;
if (sCount && Number(sCount) % 1 === 0) { if (sCount && Number(sCount) % 1 === 0) {
return getNumberArray(sCount) return getNumberArray(sCount)