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

[JavaScript] ECMAScript Omnibus #1269

Closed
Thom1729 opened this issue Oct 31, 2017 · 2 comments
Closed

[JavaScript] ECMAScript Omnibus #1269

Thom1729 opened this issue Oct 31, 2017 · 2 comments

Comments

@Thom1729
Copy link
Collaborator

Thom1729 commented Oct 31, 2017

I'm creating this issue to catalog missing features in the JavaScript bundle and discuss their implementation. Once #1009 is merged it should be easy to rip through most of these in short order.

Some of these features are still moving through the standardization process and may change or even be cancelled. Implementing them exposes us to the risk of a breaking change. But countless developers already use experimental features via transpilers like Babel, and failing to support them would mean leaving them out in the cold.

In my opinion, we should add an experimental feature when it:

  • Is on the TC39 standards track.
  • Is available for practical use by developers.
  • Has a stable syntax (even if its semantics are likely to change).

These criteria are necessarily fuzzy. A stage-3 proposal is a much safer bet than a stage-0 proposal. "Available for practical use" will usually mean "implemented in Babel". Stability might best be determined by taking the sense of the TC39 meeting notes.

If we do implement an experimental feature, and that feature is cancelled or substantially altered, then we must take responsibility for updating or removing our implementation of that feature. An "expired" experimental feature is nothing but cruft.


The following features are not implemented as of May 8, 2018. Examples are largely taken from Babel or from the proposal spec.

function.sent

function* generator() {
    console.log("Sent", function.sent);
    console.log("Yield", yield);
}

Status: Stage 2
Importance: Moderate (Babel implementation)
Risk: Low.

Optional Chaining

a?.b = 42;

Status: Stage 1
Importance: Moderate (Babel implementation)
Risk: High.


Features already implemented

Class Fields (implemented in #1292)

class Bork {
  static a = 'foo'; // static property
  x = 'bar'; // public instance property
  #p = 'baz'; // private instance property
}

Numeric Separators and BigInt (implemented in #1294)

1_000_000_000
0b1010_0001_1000_0101
0xA0_B0_C0
50000n + 60n;

Asynchronous Iteration (implemented in #1341)

for await (const line of readLines(filePath)) {
  console.log(line);
}

RegExp Improvements (implemented in #1416)

/(?<=foo)$/; // Lookbehind
/\p{Script=Greek}/u; // Unicode property escapes
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u; // Named capture groups
/./s; // dotAll flag

Function parameter destructuring (implemented in #1423)

function a({ foo, bar: bar, baz: [baz1, baz2] }) {}

new.target (implemented in #1424)

class Foo {
  constructor() {
    console.log(new.target);
  }
}

import.meta (implemented in #1484)

const size = import.meta.scriptElement.dataset.size || 300;

Decorators (implemented in #1483)

@foo('bar')
class A {
  @autobind
  [method](arg) {}

  @deco
  *gen() {}

  @a.b.c(e, f)
  m() {}
}

export default @foo class {}

class A {
  @dec name = 0
}

For completeness's sake, it's worth pointing out some common language extensions that are not on the TC39 standards track: JSX, TypeScript, and Flow. The current feeling is that we should not add these extensions into the core language syntax, although a separate JSX syntax might be added at some point (#860).

@michaelblyons
Copy link
Collaborator

Optional Chaining is Stage-3! See the ECMA262 changes.

@Thom1729
Copy link
Collaborator Author

Everything here is implemented except for function.sent, which doesn't really seem to have taken off.

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

No branches or pull requests

2 participants