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

Add support for Symbol member expression in class method definition #1602

Closed
wants to merge 1 commit into from

Conversation

coado
Copy link
Contributor

@coado coado commented Jan 28, 2025

Summary:
This diff introduces support for [Symbol.<...>] as a method definition. Previously, that type of code wasn't supported and caused an exception:

export default {
  [Symbol.iterator]() {};
}

The generated output if the type is not specified should be:

declare export default {
  @iterator(): void;
}

There are a few places in react-native source that will benefit from this, like: DOMRectList, URLSeachParams, NodeList and HTMLCollection.

Changelog:
[flow-api-translator] - Added support for Symbol member expression in class method definition

Differential Revision: D68766740

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jan 28, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68766740

…acebook#1602)

Summary:


## Summary:
This diff introduces support for [Symbol.iterator] and [Symbol.asyncIterator] as a method definition in flow defs generation. It can be confirmed in the flow lexer that these are the only two tokens prefixed with `@@`. Previously, that type of code wasn't supported and caused an exception:

```js
export default {
  [Symbol.iterator]() {};
  [Symbol.asyncIterator]() {};
}
```

The generated output if the type is not specified should be:

```js
declare export default {
  @iterator(): void;
  @asyncIterator(): void;
}
```

There are a few places in react-native source that will benefit from this, like: DOMRectList, URLSeachParams, NodeList and HTMLCollection.

Changelog:
[flow-api-translator] - Added support for Symbol member expression in class method definition

Reviewed By: pieterv

Differential Revision: D68766740
coado added a commit to coado/hermes that referenced this pull request Jan 29, 2025
…acebook#1602)

Summary:


## Summary:
This diff introduces support for [Symbol.iterator] and [Symbol.asyncIterator] as a method definition in flow defs generation. It can be confirmed in the flow lexer that these are the only two tokens prefixed with `@@`. Previously, that type of code wasn't supported and caused an exception:

```js
export default {
  [Symbol.iterator]() {};
  [Symbol.asyncIterator]() {};
}
```

The generated output if the type is not specified should be:

```js
declare export default {
  @iterator(): void;
  @asyncIterator(): void;
}
```

There are a few places in react-native source that will benefit from this, like: DOMRectList, URLSeachParams, NodeList and HTMLCollection.

Changelog:
[flow-api-translator] - Added support for Symbol member expression in class method definition

Reviewed By: pieterv

Differential Revision: D68766740
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68766740

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68766740

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 1c921f4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants