diff --git a/packages/taro-components/types/common.d.ts b/packages/taro-components/types/common.d.ts index 4ef665d687f8..1eb60756e58a 100644 --- a/packages/taro-components/types/common.d.ts +++ b/packages/taro-components/types/common.d.ts @@ -165,3 +165,6 @@ export interface NetStatus { /* 视频画面的高度 */ videoHeight?: number | string } + +/** vue style type */ +export type StyleValue = string | CSSProperties | Array diff --git a/packages/taro-components/types/index.vue3.d.ts b/packages/taro-components/types/index.vue3.d.ts new file mode 100644 index 000000000000..ada7b8238417 --- /dev/null +++ b/packages/taro-components/types/index.vue3.d.ts @@ -0,0 +1,219 @@ +/** + * vue tsx @tarojs/components 类型提示文件 + * 如何使用? + * 请在醒目全局的类型文件中写入以下代码,覆盖默认的组件类型提示 + * ```typescript + * declare module '@tarojs/components' { + * export * from '@tarojs/components/types/index.vue3' + * } + * ``` + */ +import { StandardProps, StyleValue } from './common' +/** 视图容器 */ +import { CoverImageProps } from './CoverImage' +import { CoverViewProps } from './CoverView' +import { MatchMediaProps } from './MatchMedia' +import { MovableAreaProps } from './MovableArea' +import { MovableViewProps } from './MovableView' +import { PageContainerProps } from './PageContainer' +import { ScrollViewProps } from './ScrollView' +import { ShareElementProps } from './ShareElement' +import { SwiperProps } from './Swiper' +import { SwiperItemProps } from './SwiperItem' +import { ViewProps } from './View' +/** 基础内容 */ +import { IconProps } from './Icon' +import { ProgressProps } from './Progress' +import { RichTextProps } from './RichText' +import { TextProps } from './Text' +/** 表单组件 */ +import { ButtonProps } from './Button' +import { CheckboxProps } from './Checkbox' +import { CheckboxGroupProps } from './CheckboxGroup' +import { EditorProps } from './Editor' +import { FormProps } from './Form' +import { InputProps } from './Input' +import { KeyboardAccessoryProps } from './KeyboardAccessory' +import { LabelProps } from './Label' +import { PickerDateProps, PickerTimeProps, PickerRegionProps, PickerSelectorProps, PickerMultiSelectorProps } from './Picker' +import { PickerViewProps } from './PickerView' +import { RadioProps } from './Radio' +import { RadioGroupProps } from './RadioGroup' +import { SliderProps } from './Slider' +import { SwitchProps } from './Switch' +import { TextareaProps } from './Textarea' +/** 导航 */ +import { FunctionalPageNavigatorProps } from './FunctionalPageNavigator' +import { NavigatorProps } from './Navigator' +import { NavigationBarProps } from './NavigationBar' +/** 媒体组件 */ +import { AudioProps } from './Audio' +import { CameraProps } from './Camera' +import { ImageProps } from './Image' +import { LivePlayerProps } from './LivePlayer' +import { LivePusherProps } from './LivePusher' +import { VideoProps } from './Video' +import { VoipRoomProps } from './VoipRoom' +/** 地图 */ +import { MapProps } from './Map' +/** 画布 */ +import { CanvasProps } from './Canvas' +/** 开放能力 */ +import { AdProps } from './Ad' +import { AdCustomProps } from './AdCustom' +import { OfficialAccountProps } from './OfficialAccount' +import { OpenDataProps } from './OpenData' +import { WebViewProps } from './WebView' +/** 配置节点 */ +import { PageMetaProps } from './PageMeta' + +import { CustomWrapperProps } from './CustomWrapper' +import { SlotProps } from './Slot' + +// 联合类型不能用omit(比如picker) +type DistributiveOmit = T extends unknown + ? Omit + : never; + +type ReserverdProps = { + class?: any + style?: StyleValue + innerHTML?: string +} +/** 转换react的类型到vue */ +export type TransformReact2VueType

> = DistributiveOmit & ReserverdProps + +export declare class VueComponentType

> { + $props: TransformReact2VueType

+ /** webstorm 提示貌似找的是props */ + props: this['$props'] +} + +/** 视图容器 */ +declare class Block extends VueComponentType {} +declare class CoverImage extends VueComponentType {} +declare class CoverView extends VueComponentType {} +declare class MatchMedia extends VueComponentType {} +declare class MovableArea extends VueComponentType {} +declare class MovableView extends VueComponentType {} +declare class PageContainer extends VueComponentType {} +declare class ScrollView extends VueComponentType {} +declare class ShareElement extends VueComponentType {} +declare class Swiper extends VueComponentType {} +declare class SwiperItem extends VueComponentType {} +declare class View extends VueComponentType {} +/** 基础内容 */ +declare class Icon extends VueComponentType {} +declare class Progress extends VueComponentType {} +declare class RichText extends VueComponentType {} +declare class Text extends VueComponentType {} +/** 表单组件 */ +declare class Button extends VueComponentType {} +declare class Checkbox extends VueComponentType {} +declare class CheckboxGroup extends VueComponentType {} +declare class Editor extends VueComponentType {} +declare class Form extends VueComponentType {} +declare class Input extends VueComponentType {} +declare class KeyboardAccessory extends VueComponentType {} +declare class Label extends VueComponentType {} +declare class Picker extends VueComponentType {} +declare class PickerView extends VueComponentType {} +declare class PickerViewColumn extends VueComponentType {} +declare class Radio extends VueComponentType {} +declare class RadioGroup extends VueComponentType {} +declare class Slider extends VueComponentType {} +declare class Switch extends VueComponentType {} +declare class Textarea extends VueComponentType {} +/** 导航 */ +declare class FunctionalPageNavigator extends VueComponentType {} +declare class Navigator extends VueComponentType {} +declare class NavigationBar extends VueComponentType {} +/** 媒体组件 */ +declare class Audio extends VueComponentType {} +declare class Camera extends VueComponentType {} +declare class Image extends VueComponentType {} +declare class LivePlayer extends VueComponentType {} +declare class LivePusher extends VueComponentType {} +declare class Video extends VueComponentType {} +declare class VoipRoom extends VueComponentType {} +/** 地图 */ +declare class Map extends VueComponentType {} +/** 画布 */ +declare class Canvas extends VueComponentType {} +/** 开放能力 */ +declare class Ad extends VueComponentType {} +declare class AdCustom extends VueComponentType {} +declare class OfficialAccount extends VueComponentType {} +declare class OpenData extends VueComponentType {} +declare class WebView extends VueComponentType {} +/** 配置节点 */ +declare class PageMeta extends VueComponentType {} + +declare class CustomWrapper extends VueComponentType {} +declare class Slot extends VueComponentType {} + +export * from './index' + +export { + /** 视图容器 */ + Block, + CoverImage, + CoverView, + MatchMedia, + MovableArea, + MovableView, + PageContainer, + ScrollView, + ShareElement, + Swiper, + SwiperItem, + View, + /** 基础内容 */ + Icon, + Progress, + RichText, + Text, + /** 表单组件 */ + Button, + Checkbox, + CheckboxGroup, + Editor, + Form, + Input, + KeyboardAccessory, + Label, + Picker, + PickerView, + PickerViewColumn, + Radio, + RadioGroup, + Slider, + Switch, + Textarea, + /** 导航 */ + FunctionalPageNavigator, + Navigator, + NavigationBar, + /** 媒体组件 */ + Audio, + Camera, + Image, + LivePlayer, + LivePusher, + Video, + VoipRoom, + /** 地图 */ + Map, + /** 画布 */ + Canvas, + /** 开放能力 */ + Ad, + AdCustom, + OfficialAccount, + OpenData, + WebView, + /** 配置节点 */ + PageMeta, + CustomWrapper, + Slot +}