Skip to content

Commit

Permalink
fix(types): 修复部分类型自动同步错误 (#12494)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode authored Sep 20, 2022
1 parent d1fa835 commit b32214f
Show file tree
Hide file tree
Showing 25 changed files with 111 additions and 83 deletions.
11 changes: 8 additions & 3 deletions packages/taro-components/types/Ad.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface AdProps extends StandardProps {
*/
onLoad?: CommonEventFunction

/** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象event.detail = {errCode: 1002}
/** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象 event.detail = {errCode: 1002}
* @supported weapp, swan, tt, qq
*/
onError?: CommonEventFunction<AdProps.onErrorEventDetail>
Expand Down Expand Up @@ -111,10 +111,10 @@ interface AdProps extends StandardProps {
*/
testBannerType?: 'one' | 'three'

/** type 为 feeds 时广告实际宽高回调,event.detail = {width:296,height:150}
/** type 为 feeds 时广告实际宽高回调
* @supported qq
*/
onSize?: CommonEventFunction
onSize?: CommonEventFunction<AdProps.onSizeEventDetail>
}
declare namespace AdProps {
interface onErrorEventDetail {
Expand Down Expand Up @@ -191,6 +191,11 @@ declare namespace AdProps {
*/
1008
}

interface onSizeEventDetail {
width: number
height: number
}
}

/** Banner 广告
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/AdCustom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface AdCustomProps extends StandardProps {
*/
onLoad?: CommonEventFunction

/** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象event.detail = {errCode: 1002}
/** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因
* @supported weapp
*/
onError?: CommonEventFunction<AdProps.onErrorEventDetail>
Expand Down
6 changes: 4 additions & 2 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,14 @@ interface ButtonProps extends StandardProps {

/** 当 open-type 为 lifestyle 时有效。
* 当点击按钮时触发。
* event.detail = { followStatus },folllowStatus 合法值有 1、2、3,其中 1 表示已关注。2 表示用户不允许关注。3 表示发生未知错误;
* event.detail = { followStatus },followStatus 合法值有 1、2、3,其中 1 表示已关注。2 表示用户不允许关注。3 表示发生未知错误;
* 已知问题:基础库 1.0,当用户在点击按钮前已关注生活号,event.detail.followStatus 的值为 true。
* 版本要求:基础库 1.11.0 及以上
* @supported alipay
*/
onFollowLifestyle?: CommonEventFunction
onFollowLifestyle?: CommonEventFunction<{
followStatus: 1 | 2 | 3 | true
}>

/** 发送订阅类模板消息所用的模板库标题 ID ,可通过 getTemplateLibraryList 获取
* 当参数类型为 Array 时,可传递 1~3 个模板库标题 ID
Expand Down
2 changes: 0 additions & 2 deletions packages/taro-components/types/CheckboxGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ interface CheckboxGroupProps extends StandardProps, FormItemProps {
name?: string

/** `<CheckboxGroup/>` 中选中项发生改变是触发 change 事件
*
* event.detail = { value: [选中的checkbox的 value 的数组] }
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
onChange?: CommonEventFunction<{
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/types/CoverView.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentType } from 'react'
import { CommonEventFunction } from './common'
import { ViewProps } from './View'
interface CoverViewProps extends ViewProps {
/** 设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效
Expand Down
1 change: 0 additions & 1 deletion packages/taro-components/types/Editor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ interface EditorProps extends StandardProps {
onReady?: CommonEventFunction

/** 编辑器聚焦时触发
* event.detail = { html, text, delta }
* @supported weapp
*/
onFocus?: CommonEventFunction<EditorProps.editorEventDetail>
Expand Down
1 change: 0 additions & 1 deletion packages/taro-components/types/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface FormProps extends StandardProps {
reportSubmitTimeout?: number

/** 携带 form 中的数据触发 submit 事件
* event.detail = { value : {'name': 'value'} , formId: '' }
* @supported weapp, alipay, swan, tt, qq, jd, rn
*/
onSubmit?: CommonEventFunction<FormProps.onSubmitEventDetail>
Expand Down
6 changes: 0 additions & 6 deletions packages/taro-components/types/Input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,17 @@ interface InputProps extends StandardProps, FormItemProps {
onFocus?: CommonEventFunction<InputProps.inputForceEventDetail>

/** 输入框失去焦点时触发
*
* event.detail = {value: value}
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
onBlur?: CommonEventFunction<InputProps.inputValueEventDetail>

/** 点击完成按钮时触发
*
* event.detail = {value: value}
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @h5 借用[Form 组件](./form)的`onSubmit`事件来替代
*/
onConfirm?: CommonEventFunction<InputProps.inputValueEventDetail>

/** 键盘高度发生变化的时候触发此事件
*
* event.detail = {height: height, duration: duration}
* @supported weapp, qq
*/
onKeyboardHeightChange?: CommonEventFunction<InputProps.onKeyboardHeightChangeEventDetail>
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/types/LivePusher.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface LivePusherProps extends StandardProps {

/** 是否静音。即将废弃,可用 enable-mic 替代
* @default false
* @deprecated
* @supported weapp, qq
*/
muted?: boolean
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/types/Map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface MapProps extends StandardProps {
circles?: MapProps.circle[]

/** 控件(即将废弃,建议使用 cover-view 代替)
* @deprecated
* @supported weapp, alipay, swan, jd
*/
controls?: MapProps.control[]
Expand Down
34 changes: 13 additions & 21 deletions packages/taro-components/types/MovableView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ interface MovableViewProps extends Omit<StandardProps, 'animation'> {
*/
onScale?: CommonEventFunction<MovableViewProps.onScaleEventDetail>

/** 初次手指触摸后移动为横向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch
* @supported swan
*/
onHTouchMove?: TouchEventFunction

/** 初次手指触摸后移动为纵向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch
* @supported swan
*/
onVTouchMove?: TouchEventFunction

/** 开始拖动时触发
* @supported rn
*/
Expand All @@ -114,12 +104,7 @@ interface MovableViewProps extends Omit<StandardProps, 'animation'> {
/** 初次手指触摸后移动为横向的移动时触发,如果 catch 此事件,则意味着 touchmove 事件也被catch
* @supported weapp, tt
*/
htouchmove?: CommonEventFunction

/** 初次手指触摸后移动为纵向的移动时触发,如果 catch 此事件,则意味着 touchmove 事件也被catch
* @supported weapp, tt
*/
vtouchmove?: CommonEventFunction
catchTouchmove?: CommonEventFunction

/** 触摸动作开始,事件会向父节点传递。
* 版本要求: 基础库 1.11.5 及以上
Expand All @@ -139,34 +124,41 @@ interface MovableViewProps extends Omit<StandardProps, 'animation'> {
*/
onTouchMove?: CommonEventFunction

/** 初次手指触摸后移动为横向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch
* @supported swan
*/
onHTouchMove?: TouchEventFunction

/** 初次手指触摸后移动为纵向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch
* @supported swan
*/
onVTouchMove?: TouchEventFunction

/** 触摸移动事件,事件仅作用于组件,不向父节点传递。
* 版本要求: 基础库 1.11.5 及以上
* @supported alipay
*/
catchTouchMove?: CommonEventFunction

/** 触摸动作结束,事件会向父节点传递。
* 版本要求: 基础库 1.11.5 及以上
* @supported alipay
*/
onTouchEnd?: CommonEventFunction

/** 触摸动作结束,事件仅作用于组件,不向父节点传递。
* 版本要求: 基础库 1.11.5 及以上
* @supported alipay
*/
catchTouchEnd?: CommonEventFunction

/** 触摸动作被打断,如来电提醒、弹窗。
* 版本要求: 基础库 1.11.5 及以上
* @supported alipay
*/
onTouchCancel?: CommonEventFunction

/** 拖动结束触发的事件,event.detail = {x: x, y: y}。
/** 拖动结束触发的事件
* @supported alipay
*/
onChangeEnd?: CommonEventFunction
onChangeEnd?: CommonEventFunction<MovableViewProps.onChangeEventDetail>
}
declare namespace MovableViewProps {
/** 拖动过程中触发的事件 */
Expand Down
1 change: 0 additions & 1 deletion packages/taro-components/types/PageContainer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ComponentType } from 'react'
import {
StandardProps,
CommonEventFunction,
BaseEventOrigFunction,
} from './common'
interface PageContainerProps extends StandardProps {
/** 是否显示容器组件
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/types/PageMeta.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ interface PageMetaProps extends StandardProps {
*/
rootFontSize?: string

/** 页面尺寸变化时会触发 resize 事件,event.detail = { size: { windowWidth, windowHeight } }
/** 页面尺寸变化时会触发 resize 事件
* @supported weapp
*/
onResize?: CommonEventFunction<PageMetaProps.onResizeEventDetail>

/** 页面滚动时会触发 scroll 事件,event.detail = { scrollTop }
/** 页面滚动时会触发 scroll 事件
* @supported weapp, alipay
*/
onScroll?: CommonEventFunction<PageMetaProps.onScrollEventDetail>
Expand Down
10 changes: 5 additions & 5 deletions packages/taro-components/types/Picker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ interface PickerSelectorProps extends PickerStandardProps {
indicatorStyle?: StyleProp<ViewStyle>

/**
* value 改变时触发 change 事件,event.detail = {value}
* value 改变时触发 change 事件
* @supported weapp, h5, rn
*/
onChange: CommonEventFunction<PickerSelectorProps.ChangeEventDetail>
Expand Down Expand Up @@ -136,7 +136,7 @@ interface PickerMultiSelectorProps extends PickerStandardProps {
indicatorStyle?: StyleProp<ViewStyle>

/**
* 当 value 改变时触发 change 事件,event.detail = {value}
* 当 value 改变时触发 change 事件
* @supported weapp, h5, rn
*/
onChange: CommonEventFunction<PickerMultiSelectorProps.ChangeEventDetail>
Expand Down Expand Up @@ -185,7 +185,7 @@ interface PickerTimeProps extends PickerStandardProps {
end?: string

/**
* value 改变时触发 change 事件,event.detail = {value}
* value 改变时触发 change 事件
* @supported weapp, h5, rn
*/
onChange: CommonEventFunction<PickerTimeProps.ChangeEventDetail>
Expand Down Expand Up @@ -229,7 +229,7 @@ interface PickerDateProps extends PickerStandardProps {
fields?: keyof PickerDateProps.Fields

/**
* value 改变时触发 change 事件,event.detail = {value}
* value 改变时触发 change 事件
* @supported weapp, h5, rn
*/
onChange: CommonEventFunction<PickerDateProps.ChangeEventDetail>
Expand Down Expand Up @@ -276,7 +276,7 @@ interface PickerRegionProps extends PickerStandardProps {
regionData?: PickerRegionProps.RegionData[]

/**
* value 改变时触发 change 事件,event.detail = {value, code, postcode},其中字段 code 是统计用区划代码,postcode 是邮政编码
* value 改变时触发 change 事件
* @supported weapp, h5, rn
*/
onChange: CommonEventFunction<PickerRegionProps.ChangeEventDetail>
Expand Down
4 changes: 3 additions & 1 deletion packages/taro-components/types/Radio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ interface RadioProps extends StandardProps {
/** <radio-group/> 中的选中项发生变化时触发 change 事件,event.detail = {value: 选中项radio的value}
* @supported jd
*/
onChange?: CommonEventFunction
onChange?: CommonEventFunction<{
value?: string
}>
}

/** 单选项目
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/RichText.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'
import { CommonEventFunction, StandardProps } from './common'
interface RichTextProps extends StandardProps {
/** 文本是否可选,该属性会使节点显示为 block
* @default false
Expand Down
1 change: 0 additions & 1 deletion packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ interface ScrollViewProps extends StandardProps {
onScrollToLower?: CommonEventFunction

/** 滚动时触发
* `event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}`
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
onScroll?: BaseEventOrigFunction<ScrollViewProps.onScrollDetail>
Expand Down
12 changes: 9 additions & 3 deletions packages/taro-components/types/Swiper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,10 @@ interface SwiperProps extends StandardProps {
*/
disableProgrammaticAnimation?: string

/** 动画结束时会触发 animationEnd 事件,event.detail = {current, source},其中 source 的值有 autoplay 和  touch。
* 版本要求: 基础库 1.15.0 及以上
/** 动画结束时会触发 animationEnd 事件
* @supported alipay
*/
onAnimationEnd?: CommonEventFunction
onAnimationEnd?: CommonEventFunction<SwiperProps.onCommonEventDetail>

/** 滑动距离阈值,当滑动距离超过阈值时进行 swiper-item 切换。
* 版本要求:基础库 1.24.11 及以上
Expand Down Expand Up @@ -216,6 +215,13 @@ declare namespace SwiperProps {
/** 缓入缓出动画 */
easeInOutCubic
}
interface onCommonEventDetail {
/** 当前所在滑块的索引 */
current: number

/** 导致变更的原因 */
source: keyof SwiperProps.TChangeSource
}
interface onChangeEventDetail {
/** 当前所在滑块的索引 */
current: number
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-components/types/Textarea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ interface TextareaProps extends StandardProps, FormItemProps {
*/
onBlur?: CommonEventFunction<TextareaProps.onBlurEventDetail>

/** 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
/** 输入框行数变化时调用
* @supported weapp, swan, tt, qq, rn
*/
onLineChange?: CommonEventFunction<TextareaProps.onLineChangeEventDetail>

/** 当键盘输入时,触发 input 事件,event.detail = {value, cursor, keyCode}
/** 当键盘输入时,触发 input 事件
*
* **onInput 处理函数的返回值并不会反映到 textarea 上**
* @supported weapp, alipay, swan, tt, qq, h5, rn
*/
onInput?: CommonEventFunction<TextareaProps.onInputEventDetail>

/** 点击完成时, 触发 confirm 事件,event.detail = {value: value}
/** 点击完成时, 触发 confirm 事件
* @supported weapp, alipay, swan, tt, qq, rn
*/
onConfirm?: CommonEventFunction<TextareaProps.onConfirmEventDetail>
Expand Down
Loading

0 comments on commit b32214f

Please sign in to comment.