Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,191 @@ interface ReservedProps {
interface NativeComponentAttrs {
img: MpxImg
image: MpxImg
// ..
// 视图容器
'cover-image': MpxCoverImage
'cover-view': MpxCoverView
'match-media': MpxMatchMedia
'movable-area': MpxMovableArea
'movable-view': MpxMovableView
'page-container': MpxPageContainer
'root-portal': MpxRootPortal
'scroll-view': MpxScrollView
swiper: MpxSwiper
'swiper-item': MpxSwiperItem
view: MpxView

//基础内容
icon: MpxIcon
progress: MpxProgress
'rich-text': MpxRichText
selection: MpxSelection
text: MpxText
}

interface MpxImg {
src: string
}

interface MpxCoverImage {
src?: string
'referrer-policy'?: string
bindload?: Function
binderror?: Function
Comment on lines +53 to +54
Copy link

@coderabbitai coderabbitai bot Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace generic Function types with specific event handler signatures

The static analysis correctly identifies that using Function as a type is problematic as it accepts any function-like value, which can be a source of bugs. Event handlers should have specific signatures.

Consider defining specific event handler types. For example:

+// Event handler type definitions
+type EventHandler<T = any> = (event: T) => void
+type TouchEventHandler = (event: TouchEvent) => void
+type ScrollEventHandler = (event: ScrollEvent) => void

 interface MpxCoverImage {
   src?: string
   'referrer-policy'?: string
-  bindload?: Function
-  binderror?: Function
+  bindload?: EventHandler
+  binderror?: EventHandler
 }

Apply similar changes to all interfaces using Function types.

Also applies to: 89-92, 132-141, 160-162, 195-195, 206-206

🤖 Prompt for AI Agents
In packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts
at lines 53-54 and also at lines 89-92, 132-141, 160-162, 195, and 206, replace
the generic Function types used for event handlers with specific event handler
signatures that define the expected parameters and return types. Identify the
appropriate event object types for each handler and update the type annotations
accordingly to ensure type safety and clarity.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Liub1202 todo

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

}

interface MpxCoverView {
'scroll-top'?: number | string
}

interface MpxMatchMedia {
'min-width'?: number
'max-width'?: number
width?: number
'min-height'?: number
'max-height'?: number
height?: number
orientation?: string
}

interface MpxMovableArea {
'scale-area'?: boolean
}

interface MpxMovableView {
direction?: string
inertia?: boolean
'out-of-bounds'?: boolean
x?: number | string
y?: number | string
damping?: number
friction?: number
disabled?: boolean
scale?: boolean
'scale-min'?: number
'scale-max'?: number
'scale-value'?: number
animation?: boolean
bindchange?: Function
bindscale?: Function
htouchmove?: Function
vtouchmove?: Function
}

interface MpxPageContainer {
show?: boolean
duration?: number
'z-index'?: number
overlay?: boolean
position?: string
round?: boolean
'close-on-slide-down'?: boolean
'overlay-style'?: string
'custom-style'?: string
// bind:beforeenter bind:enter bind:enter bind:afterenter bind:beforeleave bind:leave bind:afterleave bind:clickoverlay
}

interface MpxRootPortal {
enable?: boolean
}

interface MpxScrollView {
'scroll-x'?: boolean
'scroll-y'?: boolean
'upper-threshold'?: number | string
'lower-threshold'?: number | string
'scroll-top'?: number | string
'scroll-left'?: number | string
'scroll-into-view'?: string
'scroll-into-view-offset'?: number
'scroll-with-animation'?: boolean
'enable-back-to-top'?: boolean
'enable-passive'?: boolean
'refresher-enabled'?: boolean
'refresher-threshold'?: number
'refresher-default-style'?: string
'refresher-background'?: string
'refresher-triggered'?: boolean
bounces?: boolean
'show-scrollbar'?: boolean
'fast-deceleration'?: boolean
binddragstart?: Function
binddragging?: Function
binddragend?: Function
bindscrolltoupper?: Function
bindscrolltolower?: Function
bindscroll?: Function
bindrefresherpulling?: Function
bindrefresherrefresh?: Function
bindrefresherrestore?: Function
bindrefresherabort?: Function
'scroll-anchoring'?: boolean
}

interface MpxSwiper {
'indicator-dots'?: boolean
'indicator-color'?: string
'indicator-active-color'?: string
autoplay?: boolean
current?: number
interval?: number
duration?: number
circular?: boolean
vertical?: boolean
'display-multiple-items'?: number
'previous-margin'?: string
'next-margin'?: string
'easing-function'?: string
direction?: string
bindchange?: Function
bindtransition?: Function
bindanimationfinish?: Function
}

interface MpxSwiperItem {
'item-id'?: string
'skip-hidden-item-layout'?: boolean
}

interface MpxView {
'hover-class'?: string
'hover-stop-propagation'?: boolean
'hover-start-time'?: number
'hover-stay-time'?: number
}

interface MpxIcon {
type: string
size?: number | string
color?: string
}

interface MpxProgress {
percent?: number
'show-info'?: boolean
'border-radius'?: number | string
'font-size'?: number | string
'stroke-width'?: number | string
color?: string
activeColor?: string
backgroundColor?: string
active?: boolean
'active-mode'?: string
duration?: number
bindactiveend?: Function
}

interface MpxRichText {
nodes?: Array<string> | string
space?: string
'user-select'?: boolean
}

interface MpxSelection {
'disabled-context-menu'?: boolean
bindselectionchange?: Function
}

interface MpxText {
selectable?: boolean
'user-select'?: boolean
}