[英]Cannot use enum values imported from GraphQL Codegen types
Whenever I import enums from graphql-codegen generated types and use their values, the app fails to start.每当我从 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 does not show any errors in the code, but the app fails to run showing the error message below. TypeScript 未在代码中显示任何错误,但应用程序无法运行并显示以下错误消息。
Android Bundling failed
SyntaxError: graphql.types.ts: Identifier 'Document' has already been declared.
export const Document = gql`
...
Use export const name = gql
query name使用
export const name = gql
查询名称
instead of: export const Document = gql
query your identifier name is likely clashing with an ambient type definition.而不是:
export const Document = gql
查询您的标识符名称可能与环境类型定义冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.