我使用了React,material-ui,Flow,Jest在我的測試中做快照的設置。TypeScript material-ui允許未在@types中定義的道具
爲了創建一致的快照,我需要在我的material-ui組件中定義id,否則它們會自動生成並且每次都會有所不同。
,所以我這樣做: <Card style = { style } id = { id ?
$ {ID} -card : null }>
這工作得很好。現在我切換到TypeScript,並有@ types/material-ui。打字稿抱怨的ID道具:
[ts] Property 'id' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Card> ...
我做錯什麼了嗎?有沒有辦法抑制這一點?我知道該組件支持傳遞一個id。