-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid using enums in favor of frozen object literals #3360
Conversation
@brainkim This is basically a revert of #3317 but with value and type sharing the same name. That said, this is a breaking change so we need to release v17 for it. |
Why is it breaking if essentially relaxes type more than the auto type included within Enums? |
ad93249
to
b3ee368
Compare
So the only breaking part of this change is that there will no longer be type-level emits of the enum values ( |
I'd sell it as a TypeScript fix for compatibility with v15 (assuming it improves compatibility with v15). |
@IvanGoncharov Let me know what sort of tests you’re expecting if you get a chance! |
@brainkim No additional tests are needed, but please fix prettier and other linters. |
@yaacovCR It's breaking as Brian showed, also it breaking for a number of other reasons, e.g. enum merging, I think we should be truthful to the community and just release a new major version and not try to hide this change under the rug. I also think this gives the opportunity to do a proper fix and not hack.
TS enums are bad but what leads us to a hacky and non-obvious solution that tries to imitate how should work in the first place. |
Hi Ivan! So you are advocating for a partial reversion of #3317 in v16? And the full change here for v17? |
b3ee368
to
612781e
Compare
@IvanGoncharov It’s technically a breaking change, but it’s unlikely to affect people according to the analysis above. It’s your call, but if it’s going in a major release, I’d like to know the timeline for said release so I can throw a bunch of |
I think it would definitely be worth fully evaluating the differences before committing. I have to agree that TypeScript enums are broken, and that export const KindMap = {
OBJECT: 'ObjectType' as const,
OBJECT_FIELD: 'ObjectField' as const
};
export type Kind = typeof KindMap[keyof typeof KindMap];
const a: Kind = KindMap.OBJECT;
const b: Kind = 'ObjectType';
export interface ASTNode {
kind: typeof KindMap.OBJECT
} |
This comment has been minimized.
This comment has been minimized.
612781e
to
69e15bd
Compare
Another data point from @ferm10n graphql/vscode-graphql#335 (comment) |
🤔 Just realized that if this merged, apollographql/federation#1345 some of my current work maybe need revert too? |
@brainkim main is now unstable, i.e. representing the next v17 alpha. Do you have any further thoughts about the best path forward, if anything in your estimation has changed, etc, etc? Would you be able to rebase this PR? |
69e15bd
to
45846f4
Compare
|
✅ Deploy Preview for compassionate-pike-271cb3 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Implements the suggestion by @benjie (#3356 (comment))