[英]Typing a React component that clones its children to add extra props in TypeScript
[英]its possible to add any value in interface Props for initialization in React Typescript?
我需要一些帮助,我只是在学习打字稿,我想限制我的 finco 的价值,但我不能按我的方式做,这可能吗? 像这样
interface Props {
finco?: string = 'TAF' | 'ACC'
}
interface Props {
finco?: 'TAF' | 'ACC'
}
如果你只是把'TAF' | 'ACC'
'TAF' | 'ACC'
作为类型,Typescript 将只接受这两个值之一作为finco
字段的值。
(好吧,也是undefined
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.