簡體   English   中英

找不到模塊“graphql-hooks”或其相應的類型聲明

[英]Cannot find module 'graphql-hooks' or its corresponding type declarations

如何在 react-native TypeScript 中安裝 graphql-hooks? 如何定義類型?

我已經使用 npm 安裝了,但這不起作用。

React native(包括 TypeScript)不應該與任何其他項目有任何不同:

npm install graphql-hooks

也許您的項目正在使用yarn

yarn add graphql-hooks

當我在標准的 create-react-app 中嘗試時,它可以工作並立即獲得 TypeScript 類型。

我認為 graphql-hooks 帶有類型。 但是,一個小技巧是創建您自己的自定義類型。 IE

創建一個index.d.ts文件並插入以下代碼

declare module 'graphql-hooks' {
    const noTypesYet: any;
    export default noTypesYet;
}

這是一篇關於創建自定義類型https 的不錯的文章://www.credera.com/blog/technology-solutions/typescript-adding-custom-type-definitions-for-existing-libraries/

暫無
暫無

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

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