Skip to content

added await.ops#234

Merged
nzakas merged 3 commits intoestree:masterfrom
anikethsaha:await.ops
Aug 17, 2020
Merged

added await.ops#234
nzakas merged 3 commits intoestree:masterfrom
anikethsaha:await.ops

Conversation

@anikethsaha
Copy link
Contributor

@anikethsaha anikethsaha commented Aug 9, 2020

Added await.ops (stage-0) to experiment

Question to reviewers :
Should it be just as addition to existing AwaitExpression

interface AwaitExpression <: Expression {
    operation: "all" | "any" | "race" | "allSettled" | undefined
}

or the full one that is currently being implemented.

interface AwaitExpression <: Expression {
type: "AwaitExpression";
argument: Expression;
operation: "all" | "any" | "race" | "allSettled" | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

To allow easy extensibility, should this be an Identifier | null so future additions won’t have to change the AST or does it make sense to strictly limit the allowed operations?

Copy link
Contributor Author

@anikethsaha anikethsaha Aug 10, 2020

Choose a reason for hiding this comment

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

In the typescript implementation of this (repl), it does throw an error so I think we need it to be strict.

Also in the spec, it is specified with the operation

image

Though I don't have strong opinion on either

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to me that current spec disallows whitespace in await.all, which TypeScript implementation currently allow

await
// some comment
   .all [Promise.resolve(1)]

then an enum looks good to me. But I believe the spec should allow whitespaces. I have submitted tc39/proposal-await.ops#12.

If whitespaces are allowed, an Identifier | null will offer position informations for tools. We had similar discussion about that on MetaProperty (thread).

Copy link
Contributor

Choose a reason for hiding this comment

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

Also agree that an enum is most appropriate here as anything other than these values would be a syntax error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the wordings before. I lean to a dedicated Identifier for tracking positional information of all if whitespaces are allowed: tc39/proposal-await.ops#13

Copy link
Member

Choose a reason for hiding this comment

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

+1 for enum. But, either way, let's remember this is an experimental PR ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR with Indentifier

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
argument: Expression;
operation: Identifier | null
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

As now the operation is an Identifier, can you add a comment that the operation.name must be one of "all" | "allSettled" | "race" | "any"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added an inline comment , let me know if that's okay.

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Thanks.

@nzakas nzakas merged commit 4c1a8ec into estree:master Aug 17, 2020
JounQin added a commit to JounQin/babel-plugin-proposal-await-ops that referenced this pull request Aug 28, 2020
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.

5 participants