Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Typescript Enums#60

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
itayronen wants to merge5 commits intoniieani:master
base:master
Choose a base branch
Loading
fromitayronen:ts-enums
Open

Conversation

itayronen
Copy link

@itayronenitayronen commentedAug 20, 2019
edited
Loading

Added a typescript unique feature: Enums

Closes#57

Added a typescript unique feature: Enums
Copy link
Owner

@niieaniniieani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It would be good to also coverconst enums before we merge.

You could also mention that this is one of few the places TypeScript deviates from ECMAScript specification, in that this is not just a type annotation, but this affects the emit too (simply stripping out the types isn't enough for TypeScriptenums).

@oriSomething
Copy link
Contributor

@niieani I'm not sure, "const enums" should be mentions, because time after time the TS team against using it in every issue arise about them

@oriSomething
Copy link
Contributor

There is missing about enums:

  • Enums are the only nominal types in TS
  • Aboutnumber enums: They are always mixed withstrings (unlike onlystring enums)
enum E { a, b } = { a: 0, b: 1, 0: "a", 1: "b" };

@itayronen
Copy link
Author

Agree const enum are not something worth covering. Its a bundle size optimization.
Number enums are not always mixes with string values, you can get the enum key by its value (and vice versa).

I'll add the info about the additional emitted code.
With that said, typescript emits more code than just enums, depends on the ES version you target. It might (Im not sure) be the only additional code if you target es7+.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@oriSomethingoriSomethingoriSomething left review comments

@niieaniniieaniniieani requested changes

@anton-botanton-botanton-bot approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Typescript Enum
4 participants
@itayronen@oriSomething@niieani@anton-bot

[8]ページ先頭

©2009-2025 Movatter.jp