mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf: improve the type of setTimeout (#11069)
* perf: improve the type of setTimeout with 'ReturnType<typeof setTimeout>' * fix: fix type 'number' is not assignable to type 'Timeout' Co-authored-by: wangjunwei <wangjunwei@nucarf.com>
This commit is contained in:
parent
ccd92a6eee
commit
e0063ae249
@ -140,7 +140,7 @@ export default defineComponent({
|
|||||||
let startMoveY: number;
|
let startMoveY: number;
|
||||||
let startScale: number;
|
let startScale: number;
|
||||||
let startDistance: number;
|
let startDistance: number;
|
||||||
let doubleTapTimer: NodeJS.Timeout | null;
|
let doubleTapTimer: ReturnType<typeof setTimeout> | null;
|
||||||
let touchStartTime: number;
|
let touchStartTime: number;
|
||||||
|
|
||||||
const onTouchStart = (event: TouchEvent) => {
|
const onTouchStart = (event: TouchEvent) => {
|
||||||
|
@ -56,7 +56,7 @@ export default defineComponent({
|
|||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
let wrapWidth = 0;
|
let wrapWidth = 0;
|
||||||
let contentWidth = 0;
|
let contentWidth = 0;
|
||||||
let startTimer: NodeJS.Timeout;
|
let startTimer: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
const wrapRef = ref<HTMLElement>();
|
const wrapRef = ref<HTMLElement>();
|
||||||
const contentRef = ref<HTMLElement>();
|
const contentRef = ref<HTMLElement>();
|
||||||
|
@ -3,7 +3,7 @@ import { mountComponent, usePopupState } from '../utils/mount-component';
|
|||||||
import VanNotify from './Notify';
|
import VanNotify from './Notify';
|
||||||
import type { NotifyMessage, NotifyOptions } from './types';
|
import type { NotifyMessage, NotifyOptions } from './types';
|
||||||
|
|
||||||
let timer: number;
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
let instance: ComponentInstance;
|
let instance: ComponentInstance;
|
||||||
|
|
||||||
const parseOptions = (message: NotifyMessage | NotifyOptions) =>
|
const parseOptions = (message: NotifyMessage | NotifyOptions) =>
|
||||||
@ -55,7 +55,7 @@ export function showNotify(options: NotifyMessage | NotifyOptions) {
|
|||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
|
|
||||||
if (options.duration! > 0) {
|
if (options.duration! > 0) {
|
||||||
timer = window.setTimeout(closeNotify, options.duration);
|
timer = setTimeout(closeNotify, options.duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -214,7 +214,7 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
|
|
||||||
let isLongPress: boolean;
|
let isLongPress: boolean;
|
||||||
let longPressTimer: NodeJS.Timeout;
|
let longPressTimer: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
const longPressStep = () => {
|
const longPressStep = () => {
|
||||||
longPressTimer = setTimeout(() => {
|
longPressTimer = setTimeout(() => {
|
||||||
|
@ -235,7 +235,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let autoplayTimer: NodeJS.Timeout;
|
let autoplayTimer: ReturnType<typeof setTimeout>;
|
||||||
|
|
||||||
const stopAutoplay = () => clearTimeout(autoplayTimer);
|
const stopAutoplay = () => clearTimeout(autoplayTimer);
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ export default defineComponent({
|
|||||||
emits: ['update:show'],
|
emits: ['update:show'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
let timer: NodeJS.Timeout;
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
let clickable = false;
|
let clickable = false;
|
||||||
|
|
||||||
const toggleClickable = () => {
|
const toggleClickable = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user