types(utils): improve isDate typing

This commit is contained in:
陈嘉涵 2020-02-01 09:51:31 +08:00
parent 1baa60f224
commit e6bd26e0aa
2 changed files with 5 additions and 4 deletions

View File

@ -214,7 +214,8 @@ export default createComponent({
if (this.zooming && touches.length === 2) {
const distance = getDistance(touches);
const scale = (this.startScale * distance) / this.startDistance;
this.scale = range(scale, +this.minZoom, +this.maxZoom);
this.setScale(scale);
}
},

View File

@ -1,8 +1,8 @@
import { isNaN } from './number';
export function isDate(date: Date): boolean {
export function isDate(val: Date): val is Date {
return (
Object.prototype.toString.call(date) === '[object Date]' &&
!isNaN(date.getTime())
Object.prototype.toString.call(val) === '[object Date]' &&
!isNaN(val.getTime())
);
}