Inline "our own" regular enums - #48161
Conversation
|
Thanks for the PR! It looks like you've changed the TSServer protocol in some way. Please ensure that any changes here don't break consumers of the current TSServer API. For some extra review, we'll ping Sheetal Nandi (@sheetalkamat), Andrew Casey (@amcasey), Matt Bierner (@mjbvz), Mine Starks (@minestarks) for you. Feel free to loop in other consumers/maintainers if necessary |
|
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
|
Can you open a bug for this instead? |
|
To help with PR housekeeping, I'm going to close this PR while it's still waiting on a bug to be created. |
I'm curious what the impact would be on the TS codebase, of inlining "our own" regular enums, i.e. all enums except those from other packages?
That's what I've done in the first commit. We could then, optionally:
--preserveConstEnumsoption (all const enums having been rewritten, regular enums are preserved anyway)That's what I've done in the second commit --- or we could omit that change if there's some remaining distinction/advantage to const enums, apart from inlining?
To inline all "our own" enums, I changed the inlining condition as follows:
i.e. inline enums if:
The advantage of inlining "our own" regular enums is that you have the option of avoiding const enums, which prevent project references from being built with
--isolatedModules. That's because project references use .d.ts files,--declarationturns non-ambient const enums into ambient const enums, and ambient const enums are incompatible with single-file transpilation (--isolatedModules).