【发布时间】:2021-01-08 08:09:10
【问题描述】:
我收到此错误Argument of type 'string' is not assignable to parameter of (a list of strings)。
useEffect(() => {
if (selectedConnection) {
wallet.connect(selectedConnection)
}
}, [selectedConnection])
selectedConnection 是一个字符串,wallet.connect 接受一个字符串。
我已经改成
selectedConnection:
| null
| 'authereum'
| 'fortmatic'
| 'frame'
| 'injected'
| 'portis'
| 'squarelink'
| 'provided'
| 'torus'
| 'walletconnect'
| 'walletlink'
它有效。
为什么这甚至是必要的?
为什么 Typescript 在这里失败了?
【问题讨论】:
标签: typescript