簡體   English   中英

“屏幕”類型上不存在屬性“getAllByRole”。 TS2339

[英]Property 'getAllByRole' does not exist on type 'Screen'. TS2339

我正在開發一個 web 應用程序,其中的前端是使用 ReactJs 構建的。當我運行代碼時,出現了上述錯誤。

 TypeScript error in My_project/src/unitTestUtils.tsx(79,27):
Property 'getAllByRole' does not exist on type 'Screen'.  TS2339

  > 79 |   const rowGroups = scope.getAllByRole("rowgroup");

當我使用// @ts-ignore抑制錯誤時,一切正常。 請告訴我如何解決此錯誤。

確保您使用的是Screen類型表單@testing-library/react lib.dom.d.ts中有一個Screen類型,由tsconfig解析

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM