简体   繁体   中英

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.

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.

Android Bundling failed

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

export const Document = gql`
...

Use export const name = gql query name

instead of: export const Document = gql query your identifier name is likely clashing with an ambient type definition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM