New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add listeners and messages types for san.component #707
Conversation
types/index.d.ts
Outdated
@@ -95,6 +95,9 @@ declare namespace san { | |||
|
|||
nodeType: NodeType.CMPT; | |||
lifeCycle: LifeCycleStage; | |||
|
|||
listeners: ComponentListener<T>[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的listeners应该是object不是array
types/index.d.ts
Outdated
@@ -95,6 +95,9 @@ declare namespace san { | |||
|
|||
nodeType: NodeType.CMPT; | |||
lifeCycle: LifeCycleStage; | |||
|
|||
listeners: ComponentListener<T>[]; | |||
messages: ComponentDefineOptionMessages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少行末分号
types/index.d.ts
Outdated
@@ -469,6 +472,11 @@ declare namespace san { | |||
nodeType: NodeType.SLOT; | |||
} | |||
|
|||
interface ComponentListener<T> { | |||
fn: DataChangeListener<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComponentListener 和 DataChangeListener不是一个东西,this的指向不同
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
有些问题,看下评论
types/index.d.ts
Outdated
@@ -469,6 +472,13 @@ declare namespace san { | |||
nodeType: NodeType.SLOT; | |||
} | |||
|
|||
interface ComponentListener<T> { | |||
[k: string]: { | |||
fn: (this: Component<T>, change: DataChangeInfo) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn 的参数是 event 啊,这个跟 Data 的listener是2个东西,别混淆了,https://github.com/baidu/san/blob/master/src/view/component.js#L471
Pull Request Test Coverage Report for Build 1816984829
💛 - Coveralls |
listeners 和 messages 不用加在 component 声明里。
|
补充 Component 的 listeners 和 messages 属性的类型