Skip to content
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

feat: WIP enums implementation #374

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

feat: WIP enums implementation #374

wants to merge 11 commits into from

Conversation

load1n9
Copy link
Member

@load1n9 load1n9 commented Aug 1, 2024

Enums support only when using the typescript flag

Copy link
Member

@eliassjogreen eliassjogreen left a comment

Choose a reason for hiding this comment

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

Remember that const enum and enum are compiled differently. I wonder if there are any TypeScript tests we could run for enums? Anyways here's the documentation for how enums are compiled.

@DonIsaac
Copy link
Contributor

DonIsaac commented Sep 3, 2024

Quick question: does this mean Nova is attempting to support most/all TypeScript syntax? e.g. is native namespace support planned?

@load1n9
Copy link
Member Author

load1n9 commented Sep 3, 2024

the idea is to make it a feature not enabled by default

@aapoalas
Copy link
Collaborator

aapoalas commented Sep 3, 2024

Quick question: does this mean Nova is attempting to support most/all TypeScript syntax? e.g. is native namespace support planned?

My thinking is that Rust feature flags shall be our friends. I'm planning on writing a blog post about this as well, but TypeScript support at the parsing level (at least) is the first one of our supported feature flags.

There hasn't really been a direct discussion on this, but most likely TS support will not include any optimisation based on types, not at least for the foreseeable future. Our bytecode machine doesn't really give much in the way of type based optimisations in the first place. But our parser, oxc's parser, supports TS out of the box and for us supporting TS mostly just means skipping the type declarations. As a result, it's an easy feature to support.

Side note: In no particular order, other feature flags I'm thinking about:

  • No array indexed property accessors and holes. (Allows array algorithms to be aggressively optimised, while breaking cases that basically only exist in conformance tests.)
  • No object hierarchy: Arrays are Arrays and not Objects. ArrayBuffers are only ABs, etc. Breaks assigning properties to these types. Breaks subtyping of all non-ordinary object classes. Breaks a lot of code. Enables a much slimmer JS variant that may be useful in certain circumstances.
  • Immutable prototypes. Prototype object, once created, is immutable. Breaks code that messes with prototypes. Makes prototype method lookup almost trivially easy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants