Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
fix(types): ts types error
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromake committed Oct 7, 2017
1 parent 67bd891 commit 6a0d702
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 53 deletions.
18 changes: 9 additions & 9 deletions src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,47 +52,47 @@ export class Component <PropsType extends IKeyValue, StateType extends IKeyValue
/**
* 在一个组件被渲染到 DOM 之前
*/
public componentWillMount?: () => void;
public componentWillMount? (): void;
/**
* 在一个组件被渲染到 DOM 之后
*/
public componentDidMount?: () => void;
public componentDidMount? (): void;
/**
* 在一个组件在 DOM 中被清除之前
*/
public componentWillUnmount?: () => void;
public componentWillUnmount? (): void;
/**
* 在新的 props 被接受之前
* @param { PropsType } nextProps
* @param { IKeyValue } nextContext
*/
public componentWillReceiveProps?: (nextProps: PropsType, nextContext: IKeyValue) => void;
public componentWillReceiveProps? (nextProps: PropsType, nextContext: IKeyValue): boolean;
/**
* 在 render() 之前. 若返回 false,则跳过 render,与 componentWillUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
* @returns { boolean }
*/
public shouldComponentUpdate?: (nextProps: PropsType, nextState: StateType, nextContext: IKeyValue) => boolean;
public shouldComponentUpdate? (nextProps: PropsType, nextState: StateType, nextContext: IKeyValue): boolean;
/**
* 在 render() 之前,与 shouldComponentUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
*/
public componentWillUpdate?: (nextProps: PropsType, nextState: StateType, nextContext: IKeyValue) => void;
public componentWillUpdate? (nextProps: PropsType, nextState: StateType, nextContext: IKeyValue): void;
/**
* 在 render() 之后
* @param { PropsType } previousProps
* @param { StateType } previousState
* @param { IKeyValue } previousContext
*/
public componentDidUpdate?: (previousProps: PropsType, previousState: StateType, previousContext: IKeyValue) => void;
public componentDidUpdate? (previousProps: PropsType, previousState: StateType, previousContext: IKeyValue): void;
/**
* 获取上下文,会被传递到所有的子组件
*/
public getChildContext?: () => IKeyValue;
public getChildContext? (): IKeyValue;

public h?: typeof h;
/**
Expand Down Expand Up @@ -172,7 +172,7 @@ export class Component <PropsType extends IKeyValue, StateType extends IKeyValue
* 手动的同步更新dom
* @param callback 回调
*/
public forceUpdate(callback: () => void) {
public forceUpdate(callback?: () => void) {
if (callback) {
this._renderCallbacks = this._renderCallbacks || [];
this._renderCallbacks.push(callback);
Expand Down
88 changes: 44 additions & 44 deletions types/zreact.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,49 +117,49 @@ declare namespace zreact {
*/
prevContext?: $private.IKeyValue;
/**
* 在一个组件被渲染到 DOM 之前
*/
componentWillMount?: () => void;
/**
* 在一个组件被渲染到 DOM 之后
*/
componentDidMount?: () => void;
/**
* 在一个组件在 DOM 中被清除之前
*/
componentWillUnmount?: () => void;
/**
* 在新的 props 被接受之前
* @param { PropsType } nextProps
* @param { IKeyValue } nextContext
*/
componentWillReceiveProps?: (nextProps: PropsType, nextContext: $private.IKeyValue) => void;
/**
* 在 render() 之前. 若返回 false,则跳过 render,与 componentWillUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
* @returns { boolean }
*/
shouldComponentUpdate?: (nextProps: PropsType, nextState: StateType, nextContext: $private.IKeyValue) => boolean;
/**
* 在 render() 之前,与 shouldComponentUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
*/
componentWillUpdate?: (nextProps: PropsType, nextState: StateType, nextContext: $private.IKeyValue) => void;
/**
* 在 render() 之后
* @param { PropsType } previousProps
* @param { StateType } previousState
* @param { IKeyValue } previousContext
*/
componentDidUpdate?: (previousProps: PropsType, previousState: StateType, previousContext: $private.IKeyValue) => void;
/**
* 获取上下文,会被传递到所有的子组件
*/
getChildContext?: () => $private.IKeyValue;
* 在一个组件被渲染到 DOM 之前
*/
public componentWillMount? (): void;
/**
* 在一个组件被渲染到 DOM 之后
*/
public componentDidMount? (): void;
/**
* 在一个组件在 DOM 中被清除之前
*/
public componentWillUnmount? (): void;
/**
* 在新的 props 被接受之前
* @param { PropsType } nextProps
* @param { IKeyValue } nextContext
*/
public componentWillReceiveProps? (nextProps: PropsType, nextContext: $private.IKeyValue): boolean;
/**
* 在 render() 之前. 若返回 false,则跳过 render,与 componentWillUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
* @returns { boolean }
*/
public shouldComponentUpdate? (nextProps: PropsType, nextState: StateType, nextContext: $private.IKeyValue): boolean;
/**
* 在 render() 之前,与 shouldComponentUpdate 互斥
* @param { PropsType } nextProps
* @param { StateType } nextState
* @param { IKeyValue } nextContext
*/
public componentWillUpdate? (nextProps: PropsType, nextState: StateType, nextContext: $private.IKeyValue): void;
/**
* 在 render() 之后
* @param { PropsType } previousProps
* @param { StateType } previousState
* @param { IKeyValue } previousContext
*/
public componentDidUpdate? (previousProps: PropsType, previousState: StateType, previousContext: $private.IKeyValue): void;
/**
* 获取上下文,会被传递到所有的子组件
*/
public getChildContext? (): $private.IKeyValue;
/**
* 子组件
*/
Expand Down Expand Up @@ -199,7 +199,7 @@ declare namespace zreact {
* 手动的同步更新dom
* @param callback 回调
*/
forceUpdate(callback: () => void): void;
forceUpdate(callback?: () => void): void;
/**
* 用来生成VNode的函数,一定要继承后覆盖
* @param props
Expand Down

0 comments on commit 6a0d702

Please sign in to comment.