Closed chrisae closed 5 years ago
I see,
I thought that string enum always generate a corresponding object so I couldn't use enum in declaration files... shame on me :cry:
Thanks for the info, will be updated shortly.
Thanks for the quick reply and the update :-)
Should be fixed in 1.3.0
I figured out that const enum
also works with global declaration, so it's a breaking change (as before graphql enum will be generated as string union under global scope)
Cheers!
Reopen as I realised that export const enum
won't generate objects at run time, so any code that uses the enum as run time value will break. e.g: const allRoles = _.values(Roles)
I'll just need to check if user is generating code as type declaration or module :smile:
Using a
const enum
gives you the possibility to setin the
tsconfig.json
which will inline used enum values. Otherwise you'll get a runtime error because the enum is not available.See: https://github.com/Microsoft/TypeScript/issues/1689