diff --git a/packages/area/index.ts b/packages/area/index.ts index 5503fdc6..ea338929 100644 --- a/packages/area/index.ts +++ b/packages/area/index.ts @@ -102,7 +102,7 @@ VantComponent({ onChange(event: WechatMiniprogram.CustomEvent) { const { index, picker, value } = event.detail; this.code = value[index].code; - this.setValues().then(() => { + this.setValues()?.then(() => { this.$emit('change', { picker, values: this.parseValues(picker.getValues()), diff --git a/packages/calendar/components/month/index.ts b/packages/calendar/components/month/index.ts index 5256888c..913d4d19 100644 --- a/packages/calendar/components/month/index.ts +++ b/packages/calendar/components/month/index.ts @@ -10,7 +10,7 @@ interface Day { date: Date; type: string; text: number; - bottomInfo: string; + bottomInfo?: string; } VantComponent({ @@ -125,13 +125,13 @@ VantComponent({ getRangeDayType(day) { const { currentDate, allowSameDay } = this.data; if (!Array.isArray(currentDate)) { - return; + return ''; } const [startDay, endDay] = currentDate; if (!startDay) { - return; + return ''; } const compareToStart = compareDay(day, startDay); @@ -157,6 +157,8 @@ VantComponent({ if (compareToStart > 0 && compareToEnd < 0) { return 'middle'; } + + return ''; }, getDayType(day) { @@ -178,6 +180,8 @@ VantComponent({ if (type === 'range') { return this.getRangeDayType(day); } + + return ''; }, getBottomInfo(type) { diff --git a/packages/calendar/index.ts b/packages/calendar/index.ts index eb7e8bdb..47bbec3a 100644 --- a/packages/calendar/index.ts +++ b/packages/calendar/index.ts @@ -272,7 +272,7 @@ VantComponent({ } }, - select(date, complete) { + select(date, complete?: boolean) { if (complete && this.data.type === 'range') { const valid = this.checkRange(date); diff --git a/packages/circle/index.ts b/packages/circle/index.ts index 1645a938..419dfbeb 100644 --- a/packages/circle/index.ts +++ b/packages/circle/index.ts @@ -68,7 +68,7 @@ VantComponent({ }, methods: { - getContext() { + getContext(): Promise { const { type, size } = this.data; if (type === '' || !canIUseCanvas2d()) { @@ -108,7 +108,10 @@ VantComponent({ Object.keys(color) .sort((a, b) => parseFloat(a) - parseFloat(b)) .map((key) => - LinearColor.addColorStop(parseFloat(key) / 100, color[key]) + LinearColor.addColorStop( + parseFloat(key) / 100, + color[key] as string + ) ); this.hoverColor = LinearColor; }); @@ -118,7 +121,7 @@ VantComponent({ return Promise.resolve(); }, - presetCanvas(context, strokeStyle, beginAngle, endAngle, fill) { + presetCanvas(context, strokeStyle, beginAngle, endAngle, fill?: string) { const { strokeWidth, lineCap, clockwise, size } = this.data; const position = size / 2; const radius = position - strokeWidth / 2; diff --git a/packages/common/utils.ts b/packages/common/utils.ts index dc6dc0ea..9fe49709 100644 --- a/packages/common/utils.ts +++ b/packages/common/utils.ts @@ -15,7 +15,7 @@ export function nextTick(cb: (...args: any[]) => void) { } } -let systemInfo: WechatMiniprogram.GetSystemInfoSyncResult; +let systemInfo: WechatMiniprogram.SystemInfo; export function getSystemInfoSync() { if (systemInfo == null) { systemInfo = wx.getSystemInfoSync(); diff --git a/packages/datetime-picker/index.ts b/packages/datetime-picker/index.ts index 804dde1d..e763f0f1 100644 --- a/packages/datetime-picker/index.ts +++ b/packages/datetime-picker/index.ts @@ -145,9 +145,8 @@ VantComponent({ const { filter } = this.data; const results = this.getRanges().map(({ type, range }) => { let values = times(range[1] - range[0] + 1, (index) => { - let value = range[0] + index; - value = type === 'year' ? `${value}` : padZero(value); - return value; + const value = range[0] + index; + return type === 'year' ? `${value}` : padZero(value); }); if (filter) { diff --git a/packages/picker-column/index.ts b/packages/picker-column/index.ts index 092ee276..cdd4f624 100644 --- a/packages/picker-column/index.ts +++ b/packages/picker-column/index.ts @@ -113,7 +113,7 @@ VantComponent({ : option; }, - setIndex(index: number, userAction: boolean) { + setIndex(index: number, userAction?: boolean) { const { data } = this; index = this.adjustIndex(index) || 0; const offset = -index * data.itemHeight; diff --git a/packages/slider/index.ts b/packages/slider/index.ts index 6d79cc35..53e89cb3 100644 --- a/packages/slider/index.ts +++ b/packages/slider/index.ts @@ -89,7 +89,7 @@ VantComponent({ }); }, - updateValue(value: number, end: boolean, drag: boolean) { + updateValue(value: number, end?: boolean, drag?: boolean) { value = this.format(value); const { min } = this.data; const width = `${((value - min) * 100) / this.getRange()}%`; diff --git a/packages/sticky/index.ts b/packages/sticky/index.ts index e6fad06e..f4406408 100644 --- a/packages/sticky/index.ts +++ b/packages/sticky/index.ts @@ -51,7 +51,7 @@ VantComponent({ }, methods: { - onScroll({ scrollTop } = {}) { + onScroll({ scrollTop }: { scrollTop?: number } = {}) { const { container, offsetTop, disabled } = this.data; if (disabled) { diff --git a/packages/uploader/index.ts b/packages/uploader/index.ts index 30dc57fd..0ab1c44f 100644 --- a/packages/uploader/index.ts +++ b/packages/uploader/index.ts @@ -82,7 +82,7 @@ VantComponent({ this.setData({ lists, isInCount: lists.length < maxCount }); }, - getDetail(index) { + getDetail(index?: number) { return { name: this.data.name, index: index == null ? this.data.fileList.length : index,