Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix: 修复 WebStrom 中组件不自动提示属性的问题 (#1203)
Browse files Browse the repository at this point in the history
* fix(one): 由于类型声明文件的不当导致无法进行智能提示

* fix(ali): 显示声明 ali 组件类型

* fix(wechat): 显示声明 wechat 组件类型

* fix(toutiao): 显示声明 toutiao 组件类型

* fix: tips demo

* Revert "fix: tips demo"

This reverts commit c856612

* fix: remove FAQ
  • Loading branch information
coffee377 committed Aug 5, 2020
1 parent 0c2bd51 commit b3b7a8b
Show file tree
Hide file tree
Showing 111 changed files with 237 additions and 142 deletions.
10 changes: 0 additions & 10 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ Remax 支持直接使用原生组件库。具体请参考 [小程序自定义组

具体可参考 [跨平台开发](/guide/one)

## WebStorm IDE 编辑器下 api 类型无提示问题

原因是非项目的直接依赖,WebStorm 就不会去索引它。以 wechat 平台为例,我们进行以下操作即可:

把 node_modules/@remax/wechat 这个目录设置为 “not excluded”

[相关 issue 链接](https://github.com/remaxjs/remax/issues/598)

<img width="800" src="https://gw.alipayobjects.com/mdn/rms_a6d2d8/afts/img/A*HkStQ4JvAyYAAAAAAAAAAABkARQnAQ" />

## 使用高阶组件导致页面的生命周期未调用

如果使用了 Redux 的 connect ,请将 connect 的 option.forwardRef 设置为 true[文档](https://react-redux.js.org/api/connect#forwardref-boolean)。其它第三方库的高阶组件的处理方式也类似。原因如下。
Expand Down
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export interface ButtonProps {
onError?: (e: any) => void;
}

export const Button = createHostComponent<ButtonProps>('button');
export const Button: React.ComponentType<ButtonProps> = createHostComponent<ButtonProps>('button');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Canvas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export interface CanvasProps {
onTouchCancel?: (e: any) => void;
onLongTap?: (e: any) => void;
}
export const Canvas = createHostComponent<CanvasProps>('canvas');
export const Canvas: React.ComponentType<CanvasProps> = createHostComponent<CanvasProps>('canvas');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Checkbox/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface CheckboxProps {
Expand All @@ -12,4 +13,4 @@ export interface CheckboxProps {
onChange?: (e: any) => void;
}

export const Checkbox = createHostComponent<CheckboxProps>('checkbox');
export const Checkbox: React.ComponentType<CheckboxProps> = createHostComponent<CheckboxProps>('checkbox');
5 changes: 4 additions & 1 deletion packages/remax-ali/src/hostComponents/CheckboxGroup/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface CheckboxGroupProps {
Expand All @@ -8,4 +9,6 @@ export interface CheckboxGroupProps {
onChange?: (e: any) => void;
}

export const CheckboxGroup = createHostComponent<CheckboxGroupProps>('checkbox-group');
export const CheckboxGroup: React.ComponentType<CheckboxGroupProps> = createHostComponent<CheckboxGroupProps>(
'checkbox-group'
);
5 changes: 4 additions & 1 deletion packages/remax-ali/src/hostComponents/ContactButton/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface ContactButtonProps {
Expand All @@ -10,4 +11,6 @@ export interface ContactButtonProps {
alipayCardNo?: string;
}

export const ContactButton = createHostComponent<ContactButtonProps>('contact-button');
export const ContactButton: React.ComponentType<ContactButtonProps> = createHostComponent<ContactButtonProps>(
'contact-button'
);
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/CoverImage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export interface CoverImageProps {
onTap?: (e: any) => void;
}

export const CoverImage = createHostComponent<CoverImageProps>('cover-image');
export const CoverImage: React.ComponentType<CoverImageProps> = createHostComponent<CoverImageProps>('cover-image');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/CoverView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export interface CoverViewProps {
onTap?: (e: any) => void;
}

export const CoverView = createHostComponent<CoverViewProps>('cover-view');
export const CoverView: React.ComponentType<CoverViewProps> = createHostComponent<CoverViewProps>('cover-view');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export interface FormProps {
onReset?: (e: any) => void;
}

export const Form = createHostComponent<FormProps>('form');
export const Form: React.ComponentType<FormProps> = createHostComponent<FormProps>('form');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Icon/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface IconProps {
Expand All @@ -19,4 +20,4 @@ export interface IconProps {
color?: string;
}

export const Icon = createHostComponent<IconProps>('icon');
export const Icon: React.ComponentType<IconProps> = createHostComponent<IconProps>('icon');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export interface ImageProps {
onTouchCancel?: (e: any) => void;
}

export const Image = createHostComponent<ImageProps>('image');
export const Image: React.ComponentType<ImageProps> = createHostComponent<ImageProps>('image');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export interface InputProps {
onBlur?: (e: any) => void;
}

export const Input = createHostComponent<InputProps>('input');
export const Input: React.ComponentType<InputProps> = createHostComponent<InputProps>('input');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Label/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface LabelProps {
Expand All @@ -7,4 +8,4 @@ export interface LabelProps {
className?: string;
}

export const Label = createHostComponent<LabelProps>('label');
export const Label: React.ComponentType<LabelProps> = createHostComponent<LabelProps>('label');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Lifestyle/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface LifestyleProps {
Expand All @@ -6,4 +7,4 @@ export interface LifestyleProps {
onFollow?: (e: any) => void;
}

export const Lifestyle = createHostComponent<LifestyleProps>('lifestyle');
export const Lifestyle: React.ComponentType<LifestyleProps> = createHostComponent<LifestyleProps>('lifestyle');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ export interface MapProps extends MapCoordinate {
onTap?: (e: any) => void;
}

export const Map = createHostComponent<MapProps>('map');
export const Map: React.ComponentType<MapProps> = createHostComponent<MapProps>('map');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/MovableArea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export interface MovableAreaProps {
height?: number;
}

export const MovableArea = createHostComponent<MovableAreaProps>('movable-area');
export const MovableArea: React.ComponentType<MovableAreaProps> = createHostComponent<MovableAreaProps>('movable-area');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/MovableView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export interface MovableViewProps {
onScale?: (e: any) => void;
}

export const MovableView = createHostComponent<MovableViewProps>('movable-view');
export const MovableView: React.ComponentType<MovableViewProps> = createHostComponent<MovableViewProps>('movable-view');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Navigator/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface NavigatorProps {
Expand All @@ -11,4 +12,4 @@ export interface NavigatorProps {
url: string;
}

export const Navigator = createHostComponent<NavigatorProps>('navigator');
export const Navigator: React.ComponentType<NavigatorProps> = createHostComponent<NavigatorProps>('navigator');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Picker/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface PickerProps {
Expand All @@ -11,4 +12,4 @@ export interface PickerProps {
disabled?: boolean;
onChange?: (e: any) => void;
}
export const Picker = createHostComponent<PickerProps>('picker');
export const Picker: React.ComponentType<PickerProps> = createHostComponent<PickerProps>('picker');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/PickerView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export interface PickerViewProps {
onChange?: (e: any) => void;
}

export const PickerView = createHostComponent<PickerViewProps>('picker-view');
export const PickerView: React.ComponentType<PickerViewProps> = createHostComponent<PickerViewProps>('picker-view');
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export const PickerViewColumn = createHostComponent('picker-view-column');
export const PickerViewColumn: React.ComponentType = createHostComponent('picker-view-column');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Progress/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface ProgressProps {
Expand All @@ -12,4 +13,4 @@ export interface ProgressProps {
active?: boolean;
}

export const Progress = createHostComponent<ProgressProps>('progress');
export const Progress: React.ComponentType<ProgressProps> = createHostComponent<ProgressProps>('progress');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Radio/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface RadioProps {
Expand All @@ -11,4 +12,4 @@ export interface RadioProps {
color?: string;
}

export const Radio = createHostComponent<RadioProps>('radio');
export const Radio: React.ComponentType<RadioProps> = createHostComponent<RadioProps>('radio');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/RadioGroup/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface RadioGroupProps {
Expand All @@ -8,4 +9,4 @@ export interface RadioGroupProps {
onChange?: (e: any) => void;
}

export const RadioGroup = createHostComponent<RadioGroupProps>('radio-group');
export const RadioGroup: React.ComponentType<RadioGroupProps> = createHostComponent<RadioGroupProps>('radio-group');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/RichText/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface RichTextNode {
Expand All @@ -12,4 +13,4 @@ export interface RichTextProps {
nodes?: RichTextNode[];
}

export const RichText = createHostComponent<RichTextProps>('rich-text');
export const RichText: React.ComponentType<RichTextProps> = createHostComponent<RichTextProps>('rich-text');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/ScrollView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export interface ScrollViewProps {
onTouchCancel?: (e: any) => void;
}

export const ScrollView = createHostComponent<ScrollViewProps>('scroll-view');
export const ScrollView: React.ComponentType<ScrollViewProps> = createHostComponent<ScrollViewProps>('scroll-view');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Slider/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface SliderProps {
Expand All @@ -20,4 +21,4 @@ export interface SliderProps {
onChanging?: (e: any) => void;
}

export const Slider = createHostComponent<SliderProps>('slider');
export const Slider: React.ComponentType<SliderProps> = createHostComponent<SliderProps>('slider');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Swiper/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface SwiperProps {
Expand Down Expand Up @@ -26,4 +27,4 @@ export interface SwiperProps {
onAnimationEnd?: (e: any) => void;
}

export const Swiper = createHostComponent<SwiperProps>('swiper');
export const Swiper: React.ComponentType<SwiperProps> = createHostComponent<SwiperProps>('swiper');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/SwiperItem/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface SwiperItemProps {
readonly dataset?: DOMStringMap;
key: string;
}

export const SwiperItem = createHostComponent<SwiperItemProps>('swiper-item');
export const SwiperItem: React.ComponentType<SwiperItemProps> = createHostComponent<SwiperItemProps>('swiper-item');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/Switch/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface SwitchProps {
Expand All @@ -12,4 +13,4 @@ export interface SwitchProps {
onChange?: (e: any) => void;
}

export const Switch = createHostComponent<SwitchProps>('switch');
export const Switch: React.ComponentType<SwitchProps> = createHostComponent<SwitchProps>('switch');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export interface TextProps {
onClick?: (e: any) => void;
}

export const Text = createHostComponent<TextProps>('text');
export const Text: React.ComponentType<TextProps> = createHostComponent<TextProps>('text');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Textarea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ export interface TextareaProps {
onConfirm?: (e: any) => void;
}

export const Textarea = createHostComponent<TextareaProps>('textarea');
export const Textarea: React.ComponentType<TextareaProps> = createHostComponent<TextareaProps>('textarea');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/Video/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export interface VideoProps {
onUserAction?: (e: any) => void;
}

export const Video = createHostComponent<VideoProps>('video');
export const Video: React.ComponentType<VideoProps> = createHostComponent<VideoProps>('video');
2 changes: 1 addition & 1 deletion packages/remax-ali/src/hostComponents/View/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export interface ViewProps {
onFirstAppear?: (e: any) => void;
}

export const View = createHostComponent<ViewProps>('view');
export const View: React.ComponentType<ViewProps> = createHostComponent<ViewProps>('view');
3 changes: 2 additions & 1 deletion packages/remax-ali/src/hostComponents/WebView/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from 'react';
import { createHostComponent } from '@remax/shared';

export interface WebViewProps {
Expand All @@ -7,4 +8,4 @@ export interface WebViewProps {
onMessage?: (e: any) => void;
}

export const WebView = createHostComponent<WebViewProps>('web-view');
export const WebView: React.ComponentType<WebViewProps> = createHostComponent<WebViewProps>('web-view');
2 changes: 1 addition & 1 deletion packages/remax-one/src/hostComponents/Button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export interface ButtonProps extends React.AriaAttributes {
onTap?: (event: TapEvent) => void;
}

const Button = createHostComponent<ButtonProps>('button', alias, defaults);
const Button: React.ComponentType<ButtonProps> = createHostComponent<ButtonProps>('button', alias, defaults);

export default Button;
3 changes: 2 additions & 1 deletion packages/remax-one/src/hostComponents/Form/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import createHostComponent from '../../createHostComponent';
import defaults from './props/default';
import { FormProps } from './props';

export type { FormProps };

const Form = createHostComponent<FormProps>('form', null, defaults);
const Form: React.ComponentType<FormProps> = createHostComponent<FormProps>('form', null, defaults);

export default Form;
3 changes: 2 additions & 1 deletion packages/remax-one/src/hostComponents/Image/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import createHostComponent from '../../createHostComponent';
import ImageProps from './props';
import defaults from './props/default';

export type { ImageProps };

const Image = createHostComponent<ImageProps>('image', null, defaults);
const Image: React.ComponentType<ImageProps> = createHostComponent<ImageProps>('image', null, defaults);

export default Image;
5 changes: 4 additions & 1 deletion packages/remax-one/src/hostComponents/Label/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import createHostComponent from '../../createHostComponent';
import { LabelProps } from './props';

export type { LabelProps };

export default createHostComponent<LabelProps>('label', { htmlFor: 'for' });
const Label: React.ComponentType<LabelProps> = createHostComponent<LabelProps>('label', { htmlFor: 'for' });

export default Label;
5 changes: 4 additions & 1 deletion packages/remax-one/src/hostComponents/Navigator/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import createHostComponent from '../../createHostComponent';
import { NavigatorProps } from './props';
import defaults from './props/default';

export type { NavigatorProps };

export default createHostComponent<NavigatorProps>('navigator', null, defaults);
const Navigator: React.ComponentType<NavigatorProps> = createHostComponent<NavigatorProps>('navigator', null, defaults);

export default Navigator;
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as React from 'react';

export { default as defaults } from './default';

export interface NavigatorProps {
Expand Down
3 changes: 2 additions & 1 deletion packages/remax-one/src/hostComponents/Text/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as React from 'react';
import createHostComponent from '../../createHostComponent';
import TextProps from './props';
import defaults from './props/default';

export type { TextProps };

const Text = createHostComponent<TextProps>('text', null, defaults);
const Text: React.ComponentType<TextProps> = createHostComponent<TextProps>('text', null, defaults);

export default Text;
1 change: 1 addition & 0 deletions packages/remax-one/src/hostComponents/Text/props/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TapEvent } from '../../../types';
import React from 'react';

export { default as defaults } from './default';

Expand Down
Loading

1 comment on commit b3b7a8b

@vercel
Copy link

@vercel vercel bot commented on b3b7a8b Aug 5, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.