-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
typescript 怎么在可选属性上定义默认值 #66
Comments
@w1301625107 you need to set |
谢谢。但是这样怎么让人知道A 是可选的参数呢 |
It doesn't. Your // internal contract, should not be exported out
type AProps = {
value?: number
}
class A extends Component<AProps> {
static defaultProps = { value: 0 }
}
// external contract
export type ApparentAProps = JSX.LibraryManagedAttributes<typeof A, AProps> |
|
If I want to rewrite it, what is the step? |
Sorry I made a typo, it's |
This was very helpful. |
PR welcome @karfau |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! |
我想在可选属性上设置默认值,但是又不想在render 里给value 设默认值
我找了很多方法,Partial也不行,以下是我代码
错误如下
The text was updated successfully, but these errors were encountered: