Skip to content

refactor(common): Convert HttpStatusCode enum to const object#53753

Closed
JeanMeche wants to merge 1 commit intoangular:mainfrom
JeanMeche:common-httpstatuscode-object
Closed

refactor(common): Convert HttpStatusCode enum to const object#53753
JeanMeche wants to merge 1 commit intoangular:mainfrom
JeanMeche:common-httpstatuscode-object

Conversation

@JeanMeche
Copy link
Member

@JeanMeche JeanMeche commented Jan 2, 2024

Enums are not inlined, this results in the 3Kb minified output for this single enum. This commit tends to optimise that.

A presubmit will tell us how breaking this change is.

@kbrilla
Copy link
Contributor

kbrilla commented Jan 2, 2024

in this PR #51670 (comment) it is said that esbuild does inline enums?

I did find Your Twitt on this PR , and I understand that it is caused by Angualr CLI, but if thats the case probably rest of enums from #51670 could use the same treatment

@JeanMeche
Copy link
Member Author

@kbrilla It does only when directly fed TS code : esbuild

But if you pass it the TSC output like the CLI does its doesn't : esbuild

We just discovered that.

@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch from 02be978 to 11e132c Compare January 2, 2024 10:33
@kbrilla
Copy link
Contributor

kbrilla commented Jan 2, 2024

One more question, You can use enum as type but it cannot be done with object, also mayby not a big change but if You hover over object You loose info about value
image
image
also well small TS goodies are lost
image
image
this cannot be done
image

Also adding as const does solve some issues and improves on type
image
image

but still need to joggle with types to get same functionality
image

So is it some internal change only and to 'public' this will be unchanged or is it breaking change?

@JeanMeche
Copy link
Member Author

JeanMeche commented Jan 2, 2024

Yes, this is likely a breaking change for the reason you're mentionning : we can't use it as a type anymore.
With the PR I wanted to see how breaking it was in Google's codebase !

@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch from 11e132c to 5b67f9b Compare January 2, 2024 11:08
@JeanMeche JeanMeche marked this pull request as ready for review January 2, 2024 11:26
@pullapprove pullapprove bot requested a review from atscott January 2, 2024 11:27
@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch 3 times, most recently from daf08f4 to f83fe00 Compare January 2, 2024 12:46
@JeanMeche
Copy link
Member Author

cc @frigus02 since you worked on the removal of the const enum.

@JeanMeche JeanMeche added the area: common/http Issues related to HTTP and HTTP Client label Jan 2, 2024
@ngbot ngbot bot added this to the Backlog milestone Jan 2, 2024
@JeanMeche JeanMeche added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jan 2, 2024
@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch 2 times, most recently from 2aa538a to b372463 Compare January 2, 2024 15:10
@frigus02
Copy link
Contributor

frigus02 commented Jan 8, 2024

Hm, I wasn't aware that you typically feed Angular CLI output to esbuild instead of the TS code directly. It makes sense, though. I see that esbuild explicitly calls out that optimizing the enum emit in JS files is not supported (https://esbuild.github.io/api/#minify-considerations), which is unfortunate but also understandable from their side.

This PR seems like a reasonable solution to me. I'm not on the Angular team, though. My opinion doesn't really count 🙂.

crisbeto added a commit to crisbeto/angular that referenced this pull request Feb 17, 2024
…nums in docs

We have a couple of cases now (angular#53753 and angular#54414) where we're forced to redefine enums as object literals. These literals aren't rendered in the best way in the docs so these changes introduce a new `object-literal-as-enum` tag that we can use to mark them so they're treated for documentation purposes.
alxhub pushed a commit that referenced this pull request Feb 21, 2024
…nums in docs (#54487)

We have a couple of cases now (#53753 and #54414) where we're forced to redefine enums as object literals. These literals aren't rendered in the best way in the docs so these changes introduce a new `object-literal-as-enum` tag that we can use to mark them so they're treated for documentation purposes.

PR Close #54487
alxhub pushed a commit that referenced this pull request Feb 21, 2024
…nums in docs (#54487)

We have a couple of cases now (#53753 and #54414) where we're forced to redefine enums as object literals. These literals aren't rendered in the best way in the docs so these changes introduce a new `object-literal-as-enum` tag that we can use to mark them so they're treated for documentation purposes.

PR Close #54487
@JeanMeche JeanMeche added the action: presubmit The PR is in need of a google3 presubmit label Feb 22, 2024
@JeanMeche JeanMeche closed this Feb 29, 2024
@JeanMeche JeanMeche deleted the common-httpstatuscode-object branch February 29, 2024 13:41
@JeanMeche JeanMeche restored the common-httpstatuscode-object branch March 1, 2024 00:05
@JeanMeche JeanMeche reopened this Mar 1, 2024
@JeanMeche JeanMeche removed the action: presubmit The PR is in need of a google3 presubmit label Mar 1, 2024
@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch from b372463 to 00bde2d Compare March 1, 2024 00:07
Enums are not inlined, this results in the 3Kb minified output for this single enum.
This commit tends to optimise that.
@JeanMeche JeanMeche force-pushed the common-httpstatuscode-object branch from 00bde2d to ef26ae4 Compare March 1, 2024 00:33
@JeanMeche JeanMeche closed this Apr 15, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: common/http Issues related to HTTP and HTTP Client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants