簡體   English   中英

無法使用從 GraphQL Codegen 類型導入的枚舉值

[英]Cannot use enum values imported from GraphQL Codegen types

每當我從 graphql-codegen 生成的類型導入枚舉並使用它們的值時,應用程序都無法啟動。

import { MyEnum } from 'graphql-types.ts';

let x: MyEnum; // This works
x = MyEnum.MY_ENUM_VALUE; // Whenever I use this code, it fails

TypeScript 未在代碼中顯示任何錯誤,但應用程序無法運行並顯示以下錯誤消息。

Android Bundling failed

SyntaxError: graphql.types.ts: Identifier 'Document' has already been declared.

export const Document = gql`
...

使用export const name = gql查詢名稱

而不是: export const Document = gql查詢您的標識符名稱可能與環境類型定義沖突。

暫無
暫無

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

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